[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131203221543.GP8277@htj.dyndns.org>
Date: Tue, 3 Dec 2013 17:15:43 -0500
From: Tejun Heo <tj@...nel.org>
To: Dave Jones <davej@...hat.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
gregkh@...uxfoundation.org
Subject: Re: sysfs: use a separate locking class for open files depending on
mmap
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists