From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 3/4] chardev: Don't use i_devices inode field
Date: Tue, 4 Nov 2014 11:27:30 +0100 [thread overview]
Message-ID: <1415096851-17209-4-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1415096851-17209-1-git-send-email-jack@suse.cz>
Now that character device can be freed only after all inodes referencing
it through i_cdev are gone, we can remove all the tracking of inodes
pointing to a character device.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/char_dev.c | 22 +---------------------
include/linux/cdev.h | 1 -
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 518b3016ab92..4c155efc1556 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -390,7 +390,6 @@ static int chrdev_open(struct inode *inode, struct file *filp)
if (!p) {
/* Use reference from kobj_lookup for i_cdev ref */
inode->i_cdev = p = new;
- list_add(&inode->i_devices, &p->list);
new = NULL;
}
}
@@ -425,7 +424,6 @@ void cd_forget(struct inode *inode)
struct cdev *to_put;
spin_lock(&cdev_lock);
- list_del_init(&inode->i_devices);
to_put = inode->i_cdev;
inode->i_cdev = NULL;
spin_unlock(&cdev_lock);
@@ -433,18 +431,6 @@ void cd_forget(struct inode *inode)
cdev_put(to_put);
}
-static void cdev_purge(struct cdev *cdev)
-{
- spin_lock(&cdev_lock);
- while (!list_empty(&cdev->list)) {
- struct inode *inode;
- inode = container_of(cdev->list.next, struct inode, i_devices);
- list_del_init(&inode->i_devices);
- inode->i_cdev = NULL;
- }
- spin_unlock(&cdev_lock);
-}
-
/*
* Dummy default file-operations: the only thing this does
* is contain the open that then fills in the correct operations
@@ -515,10 +501,8 @@ void cdev_del(struct cdev *p)
static void cdev_default_release(struct kobject *kobj)
{
- struct cdev *p = container_of(kobj, struct cdev, kobj);
struct kobject *parent = kobj->parent;
- cdev_purge(p);
kobject_put(parent);
}
@@ -527,7 +511,6 @@ static void cdev_dynamic_release(struct kobject *kobj)
struct cdev *p = container_of(kobj, struct cdev, kobj);
struct kobject *parent = kobj->parent;
- cdev_purge(p);
kfree(p);
kobject_put(parent);
}
@@ -548,10 +531,8 @@ static struct kobj_type ktype_cdev_dynamic = {
struct cdev *cdev_alloc(void)
{
struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
- if (p) {
- INIT_LIST_HEAD(&p->list);
+ if (p)
kobject_init(&p->kobj, &ktype_cdev_dynamic);
- }
return p;
}
@@ -566,7 +547,6 @@ struct cdev *cdev_alloc(void)
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
- INIT_LIST_HEAD(&cdev->list);
kobject_init(&cdev->kobj, &ktype_cdev_default);
cdev->ops = fops;
}
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index fb4591977b03..fe00138b5106 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -13,7 +13,6 @@ struct cdev {
struct kobject kobj;
struct module *owner;
const struct file_operations *ops;
- struct list_head list;
dev_t dev;
unsigned int count;
};
--
1.8.1.4
next prev parent reply other threads:[~2014-11-04 10:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 10:27 [PATCH 0/4 v3] fs: Remove i_devices from struct inode Jan Kara
2014-11-04 10:27 ` [PATCH 1/4] blockdev: Don't use i_devices inode field Jan Kara
2014-11-04 10:27 ` [PATCH 2/4] chardev: Increment cdev reference count when i_cdev references it Jan Kara
2014-11-04 10:27 ` Jan Kara [this message]
2014-11-04 10:27 ` [PATCH 4/4] fs: Remove i_devices list head Jan Kara
2014-11-04 15:39 ` [PATCH 0/4 v3] fs: Remove i_devices from struct inode Al Viro
2014-11-04 19:47 ` Andy Lutomirski
2014-11-04 19:52 ` Andy Lutomirski
2014-11-04 20:16 ` Al Viro
2014-11-04 20:24 ` Andy Lutomirski
2014-11-04 19:55 ` Jan Kara
2014-11-04 20:14 ` Andy Lutomirski
2014-11-04 20:20 ` Al Viro
2014-11-04 20:25 ` Andy Lutomirski
-- strict thread matches above, loose matches on Subject: below --
2014-10-22 20:14 [PATCH 0/4 v2] " Jan Kara
2014-10-22 20:14 ` [PATCH 3/4] chardev: Don't use i_devices inode field Jan Kara
2014-11-04 9:54 ` Christoph Hellwig
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=1415096851-17209-4-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).