From: Chris Wedgwood <cw@f00f.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>,
Chris Mason <mason@suse.com>
Subject: [PATCH] 2.4.8-pre3 fsync entire path (+reiserfs fsync semantic change patch)
Date: Sat, 4 Aug 2001 10:01:43 +1200 [thread overview]
Message-ID: <20010804100143.A17774@weta.f00f.org> (raw)
In-Reply-To: <01080315090600.01827@starship> <Pine.GSO.4.21.0108031400590.3272-100000@weyl.math.psu.edu> <9keqr6$egl$1@penguin.transmeta.com>
In-Reply-To: <9keqr6$egl$1@penguin.transmeta.com>
[-- Attachment #1: Type: text/plain, Size: 863 bytes --]
On Fri, Aug 03, 2001 at 06:34:14PM +0000, Linus Torvalds wrote:
fsync(int fd)
{
dentry = fdget(fd);
do_fsync(dentry);
for (;;) {
tmp = dentry;
dentry = dentry->d_parent;
if (dentry == tmp)
break;
do_fdatasync(dentry);
}
}
I really like this idea. Can people please try out the attached patch?
Please note, it contains a couple of things that need not be there in
the final version.
Note, there is also a reiserfs fix in here because we can call
f_op->fsync on a directory and without this fix it will BUG! Chris,
perhaps you can suggest a better fix?
Linus, one more thing --- the first argument to ->fsync is struct file*
and nothing uses it, I'd like to blow it away or would you prefer we
wait to 2.5.x as its essentially and API change and will break XFS,
JFS, etc.
--cw
[-- Attachment #2: 2.4.8-pre3_fsync-entire-path.patch --]
[-- Type: text/plain, Size: 2056 bytes --]
diff -Nur --exclude=*.o --exclude=*~ linux-2.4.8-pre3/fs/buffer.c linux-2.4.8-pre3+expt/fs/buffer.c
--- linux-2.4.8-pre3/fs/buffer.c Wed Jul 25 19:03:05 2001
+++ linux-2.4.8-pre3+expt/fs/buffer.c Sat Aug 4 10:53:07 2001
@@ -379,33 +379,45 @@
asmlinkage long sys_fsync(unsigned int fd)
{
- struct file * file;
- struct dentry * dentry;
- struct inode * inode;
+ struct file *file;
+ struct dentry *dentry;
+ struct inode *inode;
int err;
err = -EBADF;
file = fget(fd);
if (!file)
goto out;
-
- dentry = file->f_dentry;
- inode = dentry->d_inode;
-
err = -EINVAL;
if (!file->f_op || !file->f_op->fsync)
goto out_putf;
- /* We need to protect against concurrent writers.. */
- down(&inode->i_sem);
- filemap_fdatasync(inode->i_mapping);
- err = file->f_op->fsync(file, dentry, 0);
- filemap_fdatawait(inode->i_mapping);
- up(&inode->i_sem);
+ /* walk the path (dentry chain) fsync'ing everything along
+ it. This algorithm to do "do what the user _expects_ you to
+ do" was suggested by Linus. --cw */
+ dentry = file->f_dentry;
+ do {
+ inode = dentry->d_inode;
+ /* We need to protect against concurrent writers.. */
+ down(&inode->i_sem);
+ filemap_fdatasync(inode->i_mapping);
+ err = -EINVAL;
+ if (!file->f_op || !file->f_op->fsync)
+ goto out_putf;
+ err = file->f_op->fsync(file, dentry, 0);
+ filemap_fdatawait(inode->i_mapping);
+ up(&inode->i_sem);
+
+ /* stop at root of fs */
+ if(dentry == dentry->d_parent)
+ break;
+
+ dentry = dentry->d_parent;
+ } while(dentry && !err);
-out_putf:
+ out_putf:
fput(file);
-out:
+ out:
return err;
}
diff -Nur --exclude=*.o --exclude=*~ linux-2.4.8-pre3/fs/reiserfs/file.c linux-2.4.8-pre3+expt/fs/reiserfs/file.c
--- linux-2.4.8-pre3/fs/reiserfs/file.c Fri Jul 20 20:37:09 2001
+++ linux-2.4.8-pre3+expt/fs/reiserfs/file.c Sat Aug 4 09:06:14 2001
@@ -90,6 +90,9 @@
lock_kernel() ;
+ if (S_ISDIR(p_s_inode->i_mode))
+ return reiserfs_dir_fsync(p_s_filp, p_s_dentry, datasync);
+
if (!S_ISREG(p_s_inode->i_mode))
BUG ();
next prev parent reply other threads:[~2001-08-03 22:01 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0108030507330F.00440@starship>
[not found] ` <Pine.GSO.4.21.0108022312211.1494-100000@weyl.math.psu.edu>
2001-08-03 13:09 ` intermediate summary of ext3-2.4-0.9.4 thread Daniel Phillips
2001-08-03 14:43 ` Horst von Brand
2001-08-03 17:49 ` Mike Castle
2001-08-04 3:23 ` Daniel Phillips
2001-08-03 18:08 ` Alexander Viro
2001-08-03 18:26 ` Daniel Phillips
2001-08-03 18:53 ` Alexander Viro
2001-08-03 20:50 ` Daniel Phillips
2001-08-04 3:43 ` Matthias Andree
2001-08-03 18:34 ` Linus Torvalds
2001-08-03 22:01 ` Chris Wedgwood [this message]
2001-08-03 22:33 ` [PATCH] 2.4.8-pre3 fsync entire path (+reiserfs fsync semantic change patch) Alexander Viro
2001-08-03 23:16 ` Chris Wedgwood
2001-08-03 23:23 ` Alexander Viro
2001-08-04 3:53 ` Matthias Andree
2001-08-04 5:48 ` Alexander Viro
2001-08-03 22:45 ` Alexander Viro
2001-08-03 23:09 ` Chris Wedgwood
2001-08-03 23:15 ` Alexander Viro
2001-08-03 23:20 ` Chris Wedgwood
2001-08-03 23:25 ` Alexander Viro
2001-08-03 23:35 ` Chris Wedgwood
2001-08-03 23:41 ` Alexander Viro
2001-08-03 23:46 ` Chris Wedgwood
2001-08-03 23:53 ` Alexander Viro
2001-08-04 7:45 ` [PATCH] 2.4.8-pre3 fsync entire path (+reiserfs fsync semanticchange patch) Hans Reiser
2001-08-04 18:31 ` Chris Wedgwood
2001-08-05 1:47 ` Alexander Viro
2001-08-08 17:22 ` [PATCH] 2.4.8-pre3 fsync entire path (+reiserfs fsync semanticchangepatch) Hans Reiser
2001-08-03 23:42 ` [PATCH] 2.4.8-pre3 fsync entire path (+reiserfs fsync semantic change patch) Alan Cox
2001-08-03 23:44 ` Chris Wedgwood
2001-08-04 1:08 ` Andrew Morton
2001-08-04 1:19 ` Chris Wedgwood
2001-08-04 1:45 ` Andrew Morton
2001-08-04 4:04 ` Matthias Andree
2001-08-04 18:30 ` Chris Wedgwood
2001-08-05 12:15 ` Matthias Andree
2001-08-05 12:32 ` Chris Wedgwood
2001-08-05 13:02 ` Matti Aarnio
2001-08-04 21:07 ` Andrew Morton
2001-08-04 21:07 ` Andrew Morton
2001-08-05 7:25 ` Chris Wedgwood
2001-08-09 13:25 ` Matthias Andree
2001-08-04 17:35 ` Jan Harkes
2001-08-04 18:18 ` Chris Wedgwood
2001-08-06 15:02 ` Chris Mason
2001-08-06 20:48 ` Chris Wedgwood
2001-08-03 22:29 ` Anton Altaparmakov
2001-08-03 23:06 ` Chris Wedgwood
2001-08-06 15:23 ` looking for resources for designing loopback filesystem dave-mlist
2001-08-06 16:11 ` Ville Herva
2001-08-03 18:36 ` intermediate summary of ext3-2.4-0.9.4 thread Matthias Andree
2001-08-03 19:16 ` Alexander Viro
2001-08-04 3:40 ` fdatasync(2) is also there (was: intermediate summary of ext3-2.4-0.9.4 thread) Matthias Andree
2001-08-05 0:28 ` Mike Castle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010804100143.A17774@weta.f00f.org \
--to=cw@f00f.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@suse.com \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).