From: Tejun Heo <tj@kernel.org>
To: Dave Jones <davej@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
gregkh@linuxfoundation.org
Subject: Re: sysfs: use a separate locking class for open files depending on mmap
Date: Tue, 3 Dec 2013 17:15:43 -0500 [thread overview]
Message-ID: <20131203221543.GP8277@htj.dyndns.org> (raw)
In-Reply-To: <20131203213649.GO8277@htj.dyndns.org>
Hello,
Can you please test whether this patch makes the lockdep warning go
away?
Thanks a lot!
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index b94f936..fccb645 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -470,6 +470,9 @@ static int sysfs_bin_mmap(struct file *file, struct vm_area_struct *vma)
struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
int rc;
+ if (!(of->sd->s_flags & SYSFS_FLAG_HAS_MMAP))
+ return -ENODEV;
+
mutex_lock(&of->mutex);
/* need of->sd for battr, its parent for kobj */
@@ -477,9 +480,6 @@ static int sysfs_bin_mmap(struct file *file, struct vm_area_struct *vma)
if (!sysfs_get_active(of->sd))
goto out_unlock;
- if (!battr->mmap)
- goto out_put;
-
rc = battr->mmap(file, kobj, battr, vma);
if (rc)
goto out_put;
@@ -851,6 +851,14 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
sd->s_attr.attr = (void *)attr;
sysfs_dirent_init_lockdep(sd);
+ if (type == SYSFS_KOBJ_BIN_ATTR) {
+ const struct bin_attribute *battr =
+ container_of(attr, struct bin_attribute, attr);
+
+ if (battr->mmap)
+ sd->s_flags |= SYSFS_FLAG_HAS_MMAP;
+ }
+
sysfs_addrm_start(&acxt);
rc = sysfs_add_one(&acxt, sd, dir_sd);
sysfs_addrm_finish(&acxt);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 0af09fb..27c1f7e 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -96,6 +96,7 @@ struct sysfs_dirent {
#define SYSFS_FLAG_MASK ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK)
#define SYSFS_FLAG_REMOVED 0x02000
+#define SYSFS_FLAG_HAS_MMAP 0x04000
static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
{
--
tejun
next prev parent reply other threads:[~2013-12-03 22:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20131128051223.45739660885@gitolite.kernel.org>
2013-12-03 18:43 ` Dave Jones
2013-12-03 21:10 ` Tejun Heo
2013-12-03 21:15 ` Dave Jones
2013-12-03 21:36 ` Tejun Heo
2013-12-03 22:15 ` Tejun Heo [this message]
2013-12-04 4:43 ` Dave Jones
2013-12-04 14:06 ` [PATCH driver-core-linus] sysfs: bail early from sysfs_bin_mmap() to avoid spurious lockdep warning Tejun Heo
2013-12-04 14:13 ` Tejun Heo
2013-12-04 14:20 ` [PATCH driver-core-linus] sysfs: give different locking key to regular and bin files Tejun Heo
2013-12-05 19:44 ` Greg KH
2013-12-05 19:52 ` Dave Jones
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=20131203221543.GP8277@htj.dyndns.org \
--to=tj@kernel.org \
--cc=davej@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®