linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo@conectiva.com.br>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Alexander Viro <viro@math.psu.edu>,
	Linus Torvalds <torvalds@transmeta.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: generic_osync_inode() broken?
Date: Thu, 12 Apr 2001 14:37:20 -0300 (BRT)	[thread overview]
Message-ID: <Pine.LNX.4.21.0104121412150.2892-100000@freak.distro.conectiva> (raw)


Hi, 

generic_osync_inode() (called by generic_file_write()) is not checking if
the inode being synced has the I_LOCK bit set before checking the I_DIRTY
bit.

AFAICS, the following problem can happen:

sync()
...
sync_one()
reset I_DIRTY, set I_LOCK
filemap_fdatasync() <-- #window 
write_inode()  <-- #window	
filemap_fdatawait() <-- #window
unset I_LOCK

There is no guarantee that the inode is fully synced until sync_one()
cleans the inode I_LOCK bit. 

If generic_osync_inode() checks the I_DIRTY bit (and sees it clean) during
"#window", an "O_SYNC write()" call may return to userspace without having
all the data actually synced.

If I'm not missing something here this patch should the problem. 

Comments? 

--- fs/inode.c~	Thu Mar 22 16:04:13 2001
+++ fs/inode.c	Thu Apr 12 15:18:22 2001
@@ -347,6 +347,11 @@
 #endif
 
 	spin_lock(&inode_lock);
+	while (inode->i_state & I_LOCK) {
+		spin_unlock(&inode_lock);
+		__wait_on_inode(inode);
+		spin_lock(&inode_lock);
+	}
 	if (!(inode->i_state & I_DIRTY))
 		goto out;
 	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))


             reply	other threads:[~2001-04-12 19:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-12 17:37 Marcelo Tosatti [this message]
2001-04-12 19:30 ` generic_osync_inode() broken? Linus Torvalds
2001-04-12 17:53   ` Marcelo Tosatti
2001-04-12 18:19     ` Marcelo Tosatti
2001-04-12 22:42   ` Marcelo Tosatti

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=Pine.LNX.4.21.0104121412150.2892-100000@freak.distro.conectiva \
    --to=marcelo@conectiva.com.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.com \
    --cc=torvalds@transmeta.com \
    --cc=viro@math.psu.edu \
    /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).