diff options
| author | Andrew Morton <akpm@zip.com.au> | 2002-05-27 05:13:29 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-05-27 05:13:29 -0700 |
| commit | bb772c58ab8542b34162f356faac2ed18fb7afe4 (patch) | |
| tree | cba428387bc8268d704ee4fea4fff9f8418e2c2c /include/linux | |
| parent | 7d608fac351b06ae0192bba9e116a965c2f35c5d (diff) | |
[PATCH] dirsync
An implementation of directory-synchronous mounts.
I sent this out some months ago and it didn't generate a lot of
interest. Later we had one of the usual cheery exchanges with Wietse
Venema (postfix development) and he agreed that directory synchronous
mounts were something that he could use, and that there was benefit in
implementing them in Linux. If you choose to apply this I'll push the
2.4 patch.
Patch against e2fsprogs-1.26:
http://www.zip.com.au/~akpm/linux/dirsync/e2fsprogs-1.26.patch
Patch against util-linux-2.11n:
http://www.zip.com.au/~akpm/linux/dirsync/util-linux-2.11n.patch
The kernel patch includes implementations for ext2 and ext3. It's
pretty simple.
- When dirsync is in operation against a directory, the following operations
are synchronous within that directory: create, link, unlink, symlink,
mkdir, rmdir, mknod, rename (synchronous if either the source or dest
directory is dirsync).
- dirsync is a subset of sync. So `mount -o sync' or `chattr +S'
give you everything which `mount -o dirsync' or `chattr +D' gives,
plus synchronous file writes.
- ext2's inode.i_attr_flags is unused, and is removed.
- mount /dev/foo /mnt/bar -o dirsync works as expected.
- An ext2 or ext3 directory tree can be set dirsync with `chattr +D -R'.
- dirsync is maintained as new directories are created under
a `chattr +D' directory. Like `chattr +S'.
- Other filesystems can trivially be taught about dirsync. It's just
a matter of replacing `IS_SYNC(inode)' with `IS_DIRSYNC(inode)' in
the directory update functions. IS_SYNC will still be honoured when
IS_DIRSYNC is used.
- Non-directory files do not have their dirsync flag propagated. So
an S_ISREG file which is created inside a dirsync directory will not
have its dirsync bit set. chattr needs to do this as well.
- There was a bit of version skew between e2fsprogs' idea of the
inode flags and the kernel's. That is sorted out here.
- `lsattr' shows the dirsync flag as "D". The letter "D" was
previously being used for Compressed_Dirty_File. I changed
Compressed_Dirty_File to use "Z". Is that OK?
The mount(2) manpage needs to be taught about MS_DIRSYNC.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ext2_fs.h | 9 | ||||
| -rw-r--r-- | include/linux/ext3_fs.h | 6 | ||||
| -rw-r--r-- | include/linux/fs.h | 9 |
3 files changed, 18 insertions, 6 deletions
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h index 527c8f0bf0db..e84468874422 100644 --- a/include/linux/ext2_fs.h +++ b/include/linux/ext2_fs.h @@ -211,10 +211,15 @@ struct ext2_group_desc #define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ /* End compression flags --- maybe not all used */ #define EXT2_BTREE_FL 0x00001000 /* btree format dir */ +#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ +#define EXT2_IMAGIC_FL 0x00002000 /* AFS directory */ +#define EXT2_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */ +#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ +#define EXT2_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ -#define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */ -#define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */ +#define EXT2_FL_USER_VISIBLE 0x00011FFF /* User visible flags */ +#define EXT2_FL_USER_MODIFIABLE 0x000100FF /* User modifiable flags */ /* * ioctl commands diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h index 14a44ec2534d..f8630de86518 100644 --- a/include/linux/ext3_fs.h +++ b/include/linux/ext3_fs.h @@ -203,10 +203,12 @@ struct ext3_group_desc #define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */ #define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */ #define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ +#define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */ +#define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */ -#define EXT3_FL_USER_VISIBLE 0x00005FFF /* User visible flags */ -#define EXT3_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */ +#define EXT3_FL_USER_VISIBLE 0x00015FFF /* User visible flags */ +#define EXT3_FL_USER_MODIFIABLE 0x000100FF /* User modifiable flags */ /* * Inode dynamic state flags diff --git a/include/linux/fs.h b/include/linux/fs.h index e9b490497ea8..c0ffdc99413b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -107,6 +107,7 @@ extern int leases_enable, dir_notify_enable, lease_break_time; #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ +#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ #define MS_NOATIME 1024 /* Do not update access times. */ #define MS_NODIRATIME 2048 /* Do not update directory access times */ #define MS_BIND 4096 @@ -137,6 +138,7 @@ extern int leases_enable, dir_notify_enable, lease_break_time; #define S_IMMUTABLE 16 /* Immutable file */ #define S_DEAD 32 /* removed, but still open directory */ #define S_NOQUOTA 64 /* Inode is not counted to quota */ +#define S_DIRSYNC 128 /* Directory modifications are synchronous */ /* * Note that nosuid etc flags are inode-specific: setting some file-system @@ -154,7 +156,10 @@ extern int leases_enable, dir_notify_enable, lease_break_time; #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg)) #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY) -#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC)) +#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \ + ((inode)->i_flags & S_SYNC)) +#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \ + ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA) @@ -398,7 +403,6 @@ struct inode { unsigned char i_sock; atomic_t i_writecount; - unsigned int i_attr_flags; __u32 i_generation; union { void *generic_ip; @@ -1184,6 +1188,7 @@ extern void iput(struct inode *); extern void force_delete(struct inode *); extern struct inode * igrab(struct inode *); extern ino_t iunique(struct super_block *, ino_t); +extern int inode_needs_sync(struct inode *inode); extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); extern struct inode * iget_locked(struct super_block *, unsigned long); |
