From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Dipankar Sarma <dipankar@in.ibm.com>,
Eric Dumazet <edumazet@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] fs: factor out common code in fget_light() and fget_raw_light()
Date: Mon, 13 Jan 2014 15:32:37 -0800 [thread overview]
Message-ID: <20140113233237.GR10038@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140113154840.GC6496@redhat.com>
On Mon, Jan 13, 2014 at 04:48:40PM +0100, Oleg Nesterov wrote:
> Apart from FMODE_PATH check fget_light() and fget_raw_light() are
> identical, shift the code into the new helper, __fget_light(fd, mask).
> Saves 208 bytes.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> fs/file.c | 33 +++++++++------------------------
> 1 files changed, 9 insertions(+), 24 deletions(-)
>
> diff --git a/fs/file.c b/fs/file.c
> index 4ed58a3..50c1208 100644
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -683,21 +683,21 @@ EXPORT_SYMBOL(fget_raw);
> * The fput_needed flag returned by fget_light should be passed to the
> * corresponding fput_light.
> */
> -struct file *fget_light(unsigned int fd, int *fput_needed)
> +struct file *__fget_light(unsigned int fd, fmode_t mask, int *fput_needed)
> {
> - struct file *file;
> struct files_struct *files = current->files;
> + struct file *file;
>
> *fput_needed = 0;
> if (atomic_read(&files->count) == 1) {
> file = __fcheck_files(files, fd);
> - if (file && (file->f_mode & FMODE_PATH))
> + if (file && (file->f_mode & mask))
> file = NULL;
> } else {
> rcu_read_lock();
> file = fcheck_files(files, fd);
> if (file) {
> - if (!(file->f_mode & FMODE_PATH) &&
> + if (!(file->f_mode & mask) &&
> atomic_long_inc_not_zero(&file->f_count))
> *fput_needed = 1;
> else
> @@ -709,30 +709,15 @@ struct file *fget_light(unsigned int fd, int *fput_needed)
>
> return file;
> }
> +struct file *fget_light(unsigned int fd, int *fput_needed)
> +{
> + return __fget_light(fd, FMODE_PATH, fput_needed);
> +}
> EXPORT_SYMBOL(fget_light);
>
> struct file *fget_raw_light(unsigned int fd, int *fput_needed)
> {
> - struct file *file;
> - struct files_struct *files = current->files;
> -
> - *fput_needed = 0;
> - if (atomic_read(&files->count) == 1) {
> - file = __fcheck_files(files, fd);
> - } else {
> - rcu_read_lock();
> - file = fcheck_files(files, fd);
> - if (file) {
> - if (atomic_long_inc_not_zero(&file->f_count))
> - *fput_needed = 1;
> - else
> - /* Didn't get the reference, someone's freed */
> - file = NULL;
> - }
> - rcu_read_unlock();
> - }
> -
> - return file;
> + return __fget_light(fd, 0, fput_needed);
> }
>
> void set_close_on_exec(unsigned int fd, int flag)
> --
> 1.5.5.1
>
>
next prev parent reply other threads:[~2014-01-13 23:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-07 18:12 [PATCH 0/2] rcu_dereference_check_fdtable fix/cleanups Oleg Nesterov
2014-01-07 18:13 ` [PATCH 1/2] introduce __fcheck_files() to fix rcu_dereference_check_fdtable(), kill rcu_my_thread_group_empty() Oleg Nesterov
2014-01-07 18:13 ` [PATCH 2/2] change close_files() to use rcu_lock_acquire() to shut up RCU-lockdep Oleg Nesterov
2014-01-08 13:28 ` [PATCH 0/2] rcu_dereference_check_fdtable fix/cleanups Paul E. McKenney
2014-01-08 15:19 ` Oleg Nesterov
2014-01-09 1:16 ` Paul E. McKenney
2014-01-10 15:34 ` Oleg Nesterov
2014-01-11 6:34 ` Paul E. McKenney
2014-01-11 18:19 ` [PATCH v2 " Oleg Nesterov
2014-01-11 18:19 ` [PATCH v2 1/2] introduce __fcheck_files() to fix rcu_dereference_check_fdtable(), kill rcu_my_thread_group_empty() Oleg Nesterov
2014-01-11 18:19 ` [PATCH v2 2/2] change close_files() to use rcu_dereference_raw(files->fdt) Oleg Nesterov
2014-01-11 22:27 ` [PATCH v2 0/2] rcu_dereference_check_fdtable fix/cleanups Paul E. McKenney
2014-01-13 15:47 ` [PATCH 0/3] fget*() cleanups Oleg Nesterov
2014-01-13 15:48 ` [PATCH 1/3] fs: factor out common code in fget() and fget_raw() Oleg Nesterov
2014-01-13 23:29 ` Paul E. McKenney
2014-01-13 15:48 ` [PATCH 2/3] fs: factor out common code in fget_light() and fget_raw_light() Oleg Nesterov
2014-01-13 23:32 ` Paul E. McKenney [this message]
2014-01-13 15:49 ` [PATCH 3/3] fs: __fget_light() can use __fget() in slow path Oleg Nesterov
2014-01-13 23:37 ` Paul E. McKenney
2014-01-13 23:45 ` [PATCH 0/3] fget*() cleanups Al Viro
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=20140113233237.GR10038@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--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
Powered by JetHome