Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 316894 Details for
Bug 448603
holding files under /proc/net open no longer adds to module refcount
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
new patch -- use spinlock to manage refcounts
0001-BZ-448603-proc-try-to-make-it-so-that-holding-a-pr.patch (text/plain), 3.45 KB, created by
Jeff Layton
on 2008-09-16 20:03:40 UTC
(
hide
)
Description:
new patch -- use spinlock to manage refcounts
Filename:
MIME Type:
Creator:
Jeff Layton
Created:
2008-09-16 20:03:40 UTC
Size:
3.45 KB
patch
obsolete
>From 4cae1ff9123628ce3a4999a4130ac8e0bf51df05 Mon Sep 17 00:00:00 2001 >From: Jeff Layton <jlayton@redhat.com> >Date: Tue, 16 Sep 2008 15:35:36 -0400 >Subject: [PATCH] BZ#448603: proc: try to make it so that holding a procfile open keeps a module reference > >The patch for bug 280431 moved the module refcounting from the >lookup/close codepath to the read/write codepath. This doesn't work >quite right when a program holds open a procfile and polls it >periodically. In particular, some nfs daemons do this. > >This patch attempts to put the module refcounting back into the >lookup/close codepath, but attempts to do it in a way that won't make >the refcount go negative. It's fairly impossible to do this perfectly in >a way that's kABI safe. It's still possible with this patch to do a >lookup/open and not get a reference, but it should keep us from doing >more module_put's than gets. >--- > fs/proc/inode.c | 28 +++++++++++++++++++++++++--- > include/linux/proc_fs.h | 2 ++ > 2 files changed, 27 insertions(+), 3 deletions(-) > >diff --git a/fs/proc/inode.c b/fs/proc/inode.c >index 3b15180..0d2d373 100644 >--- a/fs/proc/inode.c >+++ b/fs/proc/inode.c >@@ -60,15 +60,25 @@ static void proc_delete_inode(struct inode *inode) > { > struct proc_dir_entry *de; > struct task_struct *tsk; >+ struct proc_inode *ei = PROC_I(inode); > > /* Let go of any associated process */ >- tsk = PROC_I(inode)->task; >+ tsk = ei->task; > if (tsk) > put_task_struct(tsk); > > /* Let go of any associated proc directory entry */ >- de = PROC_I(inode)->pde; >+ de = ei->pde; > if (de) { >+ if (de->owner) { >+ spin_lock(&ei->mod_ref_lock); >+ if (ei->mod_ref_cnt > 0) { >+ --mod_ref_cnt; >+ spin_unlock(&ei->mod_ref_lock); >+ module_put(de->owner); >+ } else >+ spin_unlock(&ei->module_ref_lock); >+ } > de_put(de); > } > clear_inode(inode); >@@ -95,6 +105,8 @@ static struct inode *proc_alloc_inode(struct super_block *sb) > ei->type = 0; > ei->op.proc_get_link = NULL; > ei->pde = NULL; >+ spin_lock_init(&ei->mod_ref_lock); >+ ei->mod_ref_cnt = 0; > inode = &ei->vfs_inode; > inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; > return inode; >@@ -190,6 +202,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, > struct proc_dir_entry *de) > { > struct inode * inode; >+ struct proc_inode *ei; > > /* > * Increment the use count so the dir entry can't disappear. >@@ -202,7 +215,8 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, > if (!inode) > goto out_fail; > >- PROC_I(inode)->pde = de; >+ ei = PROC_I(inode); >+ ei->pde = de; > if (de) { > if (de->mode) { > inode->i_mode = de->mode; >@@ -213,6 +227,14 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, > inode->i_size = de->size; > if (de->nlink) > inode->i_nlink = de->nlink; >+ /* get a module reference if owner is non-NULL */ >+ if (de->owner) { >+ if (!try_module_get(de->owner)) >+ goto out_fail; >+ spin_lock(&ei->mod_ref_lock); >+ ++ei->mod_ref_cnt; >+ spin_unlock(&ei->mod_ref_lock); >+ } > if (de->proc_iops) > inode->i_op = de->proc_iops; > if (de->proc_fops) >diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h >index 4dec024..0e9aa56 100644 >--- a/include/linux/proc_fs.h >+++ b/include/linux/proc_fs.h >@@ -281,6 +281,8 @@ struct proc_inode { > } op; > struct proc_dir_entry *pde; > struct inode vfs_inode; >+ spinlock_t mod_ref_lock; /* protects mod_ref_cnt */ >+ int mod_ref_cnt; > }; > > static inline struct proc_inode *PROC_I(const struct inode *inode) >-- >1.5.5.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 448603
:
309114
|
309292
|
309776
|
310139
|
310142
|
316894
|
316952
|
317720