NetBSD/sys/fs/nilfs/nilfs_bswap.h

77 lines
2.2 KiB
C
Raw Normal View History

/* $NetBSD: nilfs_bswap.h,v 1.2 2009/10/22 21:50:01 bouyer Exp $ */
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll repeat my posting to tech-kern here: NiLFS stands for New implementation of Logging File System; LFS done right they claim :) It is at version 2 now and is being developed by NTT, the Japanese telecom company and recently put into the linux source tree. See http://www.nilfs.org. The on-disc format is not completely frozen and i expect at least one minor revision to come in time. The benefits of NiLFS are build-in fine-grained checkpointing, persistent snapshots, multiple mounts and very large file and media support. Every checkpoint can be transformed into a snapshot and v.v. It is said to perform very well on flash media since it is not overwriting pieces apart from a incidental update of the superblock, but that might change. It is accompanied by a cleaner to clean up the segments and recover lost space. My work is not a port of the linux code; its a new implementation. Porting the code would be more work since its very linux oriented and never written to be ported outside linux. The goal is to be fully interchangable. The code is non intrusive to other parts of the kernel. It is also very light-weight. The current state of the code is read-only access to both clean and dirty NiLFS partitions. On mounting a dirty partition it rolls forward the log to the last checkpoint. Full read-write support is however planned! Just as the linux code, mount_nilfs allows for the `head' to be mounted read/write and allows multiple read-only snapshots/checkpoint mounts next to it. By allowing the RW mount at a different snapshot for read-write it should be possible eventually to revert back to a previous state; i.e. try to upgrade a system and being able to revert to the exact state prior to the upgrade. Compared to other FS's its pretty light-weight, suitable for embedded use and on flash media. The read-only code is currently 17kb object code on NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory usage is most likely not very different from other uses though maybe a bit higher than FFS.
2009-07-18 20:31:41 +04:00
/*
* Copyright (c) 1998 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* adapted for NILFS by Reinoud Zandijk <reinoud@netbsd.org>
*
*/
#ifndef _FS_NILFS_BSWAP_H_
#define _FS_NILFS_BSWAP_H_
#include <sys/endian.h>
#include <machine/bswap.h>
#include <sys/bswap.h>
/* rest only relevant for big endian machines */
#if (BYTE_ORDER == BIG_ENDIAN)
/* inlines for access to swapped data */
static __inline uint16_t nilfs_rw16(uint16_t);
static __inline uint32_t nilfs_rw32(uint32_t);
static __inline uint64_t nilfs_rw64(uint64_t);
static __inline uint16_t
nilfs_rw16(uint16_t a)
{
return bswap16(a);
}
static __inline uint32_t
nilfs_rw32(uint32_t a)
{
return bswap32(a);
}
static __inline uint64_t
nilfs_rw64(uint64_t a)
{
return bswap64(a);
}
#else
#define nilfs_rw16(a) ((uint16_t)(a))
#define nilfs_rw32(a) ((uint32_t)(a))
#define nilfs_rw64(a) ((uint64_t)(a))
#endif
#endif /* !_FS_NILFS_BSWAP_H_ */