From: "Steve French (smfltc)" <smfltc@us.ibm.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-cifs-client@lists.samba.org
Subject: i_mutex and deadlock
Date: Fri, 23 Feb 2007 10:02:16 -0600 [thread overview]
Message-ID: <45DF1008.3090903@us.ibm.com> (raw)
A field in i_size_write (i_size_seqcount) must be protected against
simultaneous update otherwise we risk looping in i_size_read.
The suggestion in fs.h is to use i_mutex which seems too dangerous due
to the possibility of deadlock.
There are 65 places in the fs directory which lock an i_mutex, and seven
more in the mm directory. The vfs does clearly lock file inodes in
some paths before calling into a particular filesystem (nfs, ext3, cifs
etc.) - in particular for fsync but probably for others that are harder
to trace. This seems to introduce the possibility of deadlock if a
filesystem also uses i_mutex to protect file size updates
Documentation/filesystems/Locking describes the use of i_mutex (was
"i_sem" previously) and indicates that it is held by the vfs on three
additional calls on file inodes which concern me (for deadlock
possibility), setattr, truncate and unlink.
nfs seems to limit its use of i_mutex to llseek and invalidate_mapping,
and does not appear to grab the i_mutex (or any sem for that matter) to
protect i_size_write
(nfs calls i_size_write in nfs_grow_file) - and for the case of
nfs_fhget (in which they bypass i_size_write and set i_size directly)
does not seem to grab i_mutex either.
ext3 also does not use i_mutex for this purpose (protecting
i_size_write) - ony to protect a journalling ioctl.
I am concerned about using i_mutex to protect the cifs calls to
i_size_write (although it seems to fix a problem reported in i_size_read
under stress) because of the following:
1) no one else calls i_size_write AFAIK (on our file inodes)
2) we don't block inside i_size_write do we ... (so why in the world do
they take a slow mutex instead of a fast spinlock)
3) we don't really know what happens inside fsync (the paths through the
page cache code seem complex and we don't want to reenter writepage in
low memory conditions and deadlock updating the file size), and there is
some concern that the vfs takes the i_mutex in other paths on file
inodes before entering our code and could deadlock.
Any reason, why an fs shouldn't simply use something else (a spinlock)
other than i_mutex to protect the i_size_write call?
next reply other threads:[~2007-02-23 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-23 16:02 Steve French (smfltc) [this message]
2007-02-23 16:29 ` [linux-cifs-client] i_mutex and deadlock Dave Kleikamp
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=45DF1008.3090903@us.ibm.com \
--to=smfltc@us.ibm.com \
--cc=linux-cifs-client@lists.samba.org \
--cc=linux-fsdevel@vger.kernel.org \
/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).