2003-07-17 20:44:28

by Dan Behman

[permalink] [raw]
Subject: 2.6: marking individual directories as synchronous?

Hi,

I'm reading through Joseph Pranevich's great document "Wonderful World of
Linux 2.6" and I came across something that I'd love to learn more about.
In the "Block Device Support" -> "Filesystems" section, reference is made to
"Individual directories can now be marked as synchronous so that all changes
(additional files, etc.) will be atomic". I searched through the update
info at kernelnewbies but
couldn't find any more information on this - could someone please elaborate
on this? What is it and how does it work? Is there any design
documentation for this?

Thanks!

Dan Behman...

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus


2003-07-20 02:37:39

by Theodore Ts'o

[permalink] [raw]
Subject: Re: 2.6: marking individual directories as synchronous?

On Thu, Jul 17, 2003 at 04:59:20PM -0400, Dan Behman wrote:
> Hi,
>
> I'm reading through Joseph Pranevich's great document "Wonderful World of
> Linux 2.6" and I came across something that I'd love to learn more about.
> In the "Block Device Support" -> "Filesystems" section, reference is made
> to "Individual directories can now be marked as synchronous so that all
> changes (additional files, etc.) will be atomic". I searched through the
> update info at kernelnewbies but
> couldn't find any more information on this - could someone please elaborate
> on this? What is it and how does it work? Is there any design
> documentation for this?

He is is probably referring to "chattr +S". See the man page for
chattr for more information. Note that strictly speaking this does
not necessarily give you "atomic changes". It does mean that changes
are scheduled to be immediately written to disk, but that does not
guarantee atomicity, at least not for all filesystems and for all
operations. You *can* be guaranteed that system calls will not return
until the changes are on disk; note though that this does have has
some significant performance impacts.

- Ted

2003-07-22 13:05:25

by Carl Spalletta

[permalink] [raw]
Subject: Re: 2.6: marking individual directories as synchronous?

Grepping around in 2.6.0-test1 src I found:

include/linux/fs.h:
105 #define MS_DIRSYNC 128 /* Directory modifications are synchronous */
138 #define S_DIRSYNC 128 /* Directory modifications are synchronous */

Therefore, study the definitions and uses of those flags as well as
IS_DIRSYNC(), EXT3_DIRSYNC_FL, ext3_ioctl() & ext3_set_inode_flags().

For example:
[linux-2.6.0-test1]$ cscope -d -L -3 IS_DIRSYNC
...
fs/ext2/dir.c ext2_commit_chunk 71 if (IS_DIRSYNC(dir))
fs/ext3/ialloc.c ext3_new_inode 585 if (IS_DIRSYNC(inode))
fs/ext3/namei.c ext3_create 1638 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_mknod 1665 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_mkdir 1697 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_rmdir 1981 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_unlink 2033 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_symlink 2089 if (IS_DIRSYNC(dir))
fs/ext3/namei.c ext3_link 2139 if (IS_DIRSYNC(dir))
fs/minix/dir.c dir_commit_chunk 53 if (IS_DIRSYNC(dir))
fs/sysv/dir.c dir_commit_chunk 46 if (IS_DIRSYNC(dir))
fs/ufs/dir.c ufs_set_link 359 if (IS_DIRSYNC(dir))
fs/ufs/dir.c ufs_add_link 458 if (IS_DIRSYNC(dir))
fs/ufs/dir.c ufs_delete_entry 507 if (IS_DIRSYNC(inode))
...

I haven't actually played with the application of this, but it would appear
to be some combination of ioctl's and/or mount flags. Check the source for
chattr(1) to see if and how it uses the ioctl.

2003-07-22 18:42:21

by Carl Spalletta

[permalink] [raw]
Subject: Re: 2.6: marking individual directories as synchronous?

Here is further info on the use of IS_DIRSYNC in ext2.

ext2_alloc_branch() is used only in the O_DIRECT path.
ext2_commit_chunk() is called indirectly in the following paths, which provide
functionality comparable to that of ext3:

[linux-2.6.0-test1]$ fscope -func=ext2_commit_chunk

ext2_commit_chunk ext2_add_link ext2_add_nondir ext2_create
ext2_commit_chunk ext2_add_link ext2_add_nondir ext2_link
ext2_commit_chunk ext2_add_link ext2_add_nondir ext2_mknod
ext2_commit_chunk ext2_add_link ext2_add_nondir ext2_symlink
ext2_commit_chunk ext2_add_link ext2_mkdir
ext2_commit_chunk ext2_add_link ext2_rename
ext2_commit_chunk ext2_delete_entry ext2_rename
ext2_commit_chunk ext2_delete_entry ext2_unlink ext2_rmdir
ext2_commit_chunk ext2_make_empty ext2_mkdir
ext2_commit_chunk ext2_set_link ext2_rename

FOR CLARITY:

items 1-4 rotated:
ext2_create ext2_link ext2_mknod ext2_symlink
ext2_add_nondir ext2_add_nondir ext2_add_nondir ext2_add_nondir
ext2_add_link ext2_add_link ext2_add_link ext2_add_link
ext2_commit_chunk ext2_commit_chunk ext2_commit_chunk ext2_commit_chunk

items 5-8 rotated:
(null) (null) (null) ext2_rmdir
ext2_mkdir ext2_rename ext2_rename ext2_unlink
ext2_add_link ext2_add_link ext2_delete_entry ext2_delete_entry
ext2_commit_chunk ext2_commit_chunk ext2_commit_chunk ext2_commit_chunk

items 9-10 rotated:
ext2_mkdir ext2_rename
ext2_make_empty ext2_set_link
ext2_commit_chunk ext2_commit_chunk

(See this list for tool 'fscope'.)

_