From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
linux-fsdevel@vger.kernel.org,
Eric Dumazet <eric.dumazet@gmail.com>,
Benjamin LaHaise <bcrl@lhnet.ca>, Serge Hallyn <serue@us.ibm.com>,
"Eric W. Biederman" <ebiederm@aristanetworks.com>
Subject: [PATCH 1/6] sysfs: Serialize updates to the vfs inode
Date: Fri, 12 Feb 2010 19:22:23 -0800 [thread overview]
Message-ID: <1266031348-30068-1-git-send-email-ebiederm@xmission.com> (raw)
In-Reply-To: <m1mxzdstx2.fsf_-_@fess.ebiederm.org>
From: Eric W. Biederman <ebiederm@aristanetworks.com>
The vfs depends upon filesystem methods to update the
vfs inode. Sysfs adds to the normal number of places
where the vfs inode is updated by also updatng the
vfs inode in sysfs_refresh_inode.
Typically the inode mutex is used to serialize updates
to the vfs inode, but grabbing the inode mutex in
sysfs_permission and sysfs_getattr causes deadlocks,
because sometimes the vfs calls those operations with
the inode mutex held. Therefore sysfs can not use the
inode mutex to serial updates to the vfs inode.
The sysfs_mutex is acquired in all of the routines
where sysfs updates the vfs inode, and with a small
change we can consistently protext sysfs vfs inode
updates with the sysfs_mutex. To protect the sysfs
vfs inode updates with the sysfs_mutex simply requires
extending the scope of sysfs_mutex in sysfs_setattr
over inode_setattr, and over inode_change_ok (so we
have an unchanging inode when we perform the check).
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
fs/sysfs/inode.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 6a06a1d..0d09f6c 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -111,20 +111,20 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (!sd)
return -EINVAL;
+ mutex_lock(&sysfs_mutex);
error = inode_change_ok(inode, iattr);
if (error)
- return error;
+ goto out;
iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */
error = inode_setattr(inode, iattr);
if (error)
- return error;
+ goto out;
- mutex_lock(&sysfs_mutex);
error = sysfs_sd_setattr(sd, iattr);
+out:
mutex_unlock(&sysfs_mutex);
-
return error;
}
--
1.6.5.2.143.g8cc62
next prev parent reply other threads:[~2010-02-13 3:22 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-11 20:16 [PATCH 0/7] General sysfs enhancements Eric W. Biederman
2010-01-11 20:21 ` [PATCH 1/7] sysfs: Serialize updates to the vfs inode Eric W. Biederman
2010-01-12 5:41 ` Serge E. Hallyn
2010-01-11 20:21 ` [PATCH 2/7] sysfs: Pack sysfs_dirent more tightly Eric W. Biederman
2010-01-12 0:41 ` Tejun Heo
2010-01-11 20:21 ` [PATCH 3/7] sysfs: Keep an nlink count on sysfs directories Eric W. Biederman
2010-01-12 0:46 ` Tejun Heo
2010-01-12 0:53 ` Benjamin LaHaise
2010-01-12 1:06 ` Eric W. Biederman
2010-01-12 1:12 ` Benjamin LaHaise
2010-01-12 1:23 ` Eric W. Biederman
2010-01-12 6:22 ` Tejun Heo
2010-01-12 15:49 ` Valdis.Kletnieks
2010-01-12 1:02 ` Eric W. Biederman
2010-01-12 5:56 ` Serge E. Hallyn
2010-01-12 8:30 ` Eric W. Biederman
2010-01-12 12:41 ` Cornelia Huck
2010-01-12 15:34 ` Eric W. Biederman
2010-01-11 20:21 ` [PATCH 4/7] sysfs: Implement sysfs_rename_link Eric W. Biederman
2010-01-12 6:24 ` Tejun Heo
2010-01-12 17:30 ` Serge E. Hallyn
2010-01-11 20:21 ` [PATCH 5/7] driver core: Use sysfs_rename_link in device_rename Eric W. Biederman
2010-01-12 6:25 ` Tejun Heo
2010-01-12 17:34 ` Serge E. Hallyn
2010-01-11 20:21 ` [PATCH 6/7] sysfs: Pass super_block to sysfs_get_inode Eric W. Biederman
2010-01-12 17:43 ` Serge E. Hallyn
2010-01-11 20:21 ` [PATCH 7/7] sysfs: Kill unused sysfs_sb variable Eric W. Biederman
2010-01-12 17:43 ` Serge E. Hallyn
2010-01-15 21:37 ` [PATCH 0/7] General sysfs enhancements Greg KH
2010-02-13 3:20 ` [PATCH 0/6] " Eric W. Biederman
2010-02-13 3:22 ` Eric W. Biederman [this message]
2010-02-13 3:22 ` [PATCH 2/6] sysfs: Pack sysfs_dirent more tightly Eric W. Biederman
2010-02-13 3:22 ` [PATCH 3/6] sysfs: Implement sysfs_rename_link Eric W. Biederman
2010-02-13 3:22 ` [PATCH 4/6] driver core: Use sysfs_rename_link in device_rename Eric W. Biederman
2010-02-13 3:22 ` [PATCH 5/6] sysfs: Pass super_block to sysfs_get_inode Eric W. Biederman
2010-02-13 3:22 ` [PATCH 6/6] sysfs: Kill unused sysfs_sb variable Eric W. Biederman
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=1266031348-30068-1-git-send-email-ebiederm@xmission.com \
--to=ebiederm@xmission.com \
--cc=bcrl@lhnet.ca \
--cc=cornelia.huck@de.ibm.com \
--cc=ebiederm@aristanetworks.com \
--cc=eric.dumazet@gmail.com \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
--cc=tj@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
all inboxes | Powered by JetHome®