From: Andrew Morton <akpm@osdl.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [patch 01/12] fuse: fix hang on SMP
Date: Mon, 16 Oct 2006 16:51:25 -0700 [thread overview]
Message-ID: <20061016165125.4605824b.akpm@osdl.org> (raw)
In-Reply-To: <20061016162729.176738000@szeredi.hu>
On Mon, 16 Oct 2006 18:27:10 +0200
Miklos Szeredi <miklos@szeredi.hu> wrote:
> Fuse didn't always call i_size_write() with i_mutex held which caused
> rare hangs on SMP/32bit.
Yes, that is a bit of a trap. I'll maintain a patch in -mm which spits a
warning if i_size_write() is called without i_mutex held.
--- a/include/linux/fs.h~mm-only-i_size_write-debugging
+++ a/include/linux/fs.h
@@ -646,25 +646,7 @@ static inline loff_t i_size_read(struct
#endif
}
-/*
- * NOTE: unlike i_size_read(), i_size_write() does need locking around it
- * (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount
- * can be lost, resulting in subsequent i_size_read() calls spinning forever.
- */
-static inline void i_size_write(struct inode *inode, loff_t i_size)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- write_seqcount_begin(&inode->i_size_seqcount);
- inode->i_size = i_size;
- write_seqcount_end(&inode->i_size_seqcount);
-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
- preempt_disable();
- inode->i_size = i_size;
- preempt_enable();
-#else
- inode->i_size = i_size;
-#endif
-}
+void i_size_write(struct inode *inode, loff_t i_size);
static inline unsigned iminor(struct inode *inode)
{
diff -puN fs/inode.c~mm-only-i_size_write-debugging fs/inode.c
--- a/fs/inode.c~mm-only-i_size_write-debugging
+++ a/fs/inode.c
@@ -1384,6 +1384,23 @@ void __init inode_init(unsigned long mem
INIT_HLIST_HEAD(&inode_hashtable[loop]);
}
+void i_size_write(struct inode *inode, loff_t i_size)
+{
+ WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
+ write_seqcount_begin(&inode->i_size_seqcount);
+ inode->i_size = i_size;
+ write_seqcount_end(&inode->i_size_seqcount);
+#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
+ preempt_disable();
+ inode->i_size = i_size;
+ preempt_enable();
+#else
+ inode->i_size = i_size;
+#endif
+}
+EXPORT_SYMBOL(i_size_write);
+
void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
{
inode->i_mode = mode;
_
next prev parent reply other threads:[~2006-10-16 23:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-16 16:27 [patch 00/12] fuse update Miklos Szeredi
2006-10-16 16:27 ` [patch 01/12] fuse: fix hang on SMP Miklos Szeredi
2006-10-16 23:51 ` Andrew Morton [this message]
2006-10-17 12:53 ` Mike Day
2006-10-17 13:43 ` Miklos Szeredi
2006-10-16 16:27 ` [patch 02/12] document i_size_write locking rules Miklos Szeredi
2006-10-16 16:27 ` [patch 03/12] fuse: locking fix for nlookup Miklos Szeredi
2006-10-16 16:27 ` [patch 04/12] fuse: fix spurious BUG Miklos Szeredi
2006-10-16 16:27 ` [patch 05/12] fuse: fix handling of moved directory Miklos Szeredi
2006-10-16 16:27 ` [patch 06/12] fuse: fix dereferencing dentry parent Miklos Szeredi
2006-10-16 16:27 ` [patch 07/12] fuse: update userspace interface to version 7.8 Miklos Szeredi
2006-10-16 16:27 ` [patch 08/12] fuse: minor cleanup in fuse_dentry_revalidate Miklos Szeredi
2006-10-16 16:27 ` [patch 09/12] fuse: add support for block device based filesystems Miklos Szeredi
2006-10-16 16:27 ` [patch 10/12] fuse: add blksize option Miklos Szeredi
2006-10-16 16:27 ` [patch 11/12] fuse: add bmap support Miklos Szeredi
2006-10-16 16:27 ` [patch 12/12] fuse: add DESTROY operation Miklos Szeredi
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=20061016165125.4605824b.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).