public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: NeilBrown <neilb@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH 1/2] sysfs - allow attributes to request write buffer be pre-allocated.
Date: Sun, 5 Oct 2014 15:56:55 -0400	[thread overview]
Message-ID: <20141005195655.GI8549@htj.dyndns.org> (raw)
In-Reply-To: <20140930023334.13407.83407.stgit@notabene.brown>

Hello,

Generally looks good to me.  Some nitpicks follow.

On Tue, Sep 30, 2014 at 12:33:34PM +1000, NeilBrown wrote:
...
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index 4429d6d9217f..73bd5ed143cd 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -278,16 +278,12 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
>  		len = min_t(size_t, count, PAGE_SIZE);
>  	}
>  
> -	buf = kmalloc(len + 1, GFP_KERNEL);
> +	buf = of->buf;
> +	if (!buf)
> +		buf = kmalloc(len + 1, GFP_KERNEL);
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	if (copy_from_user(buf, user_buf, len)) {
> -		len = -EFAULT;
> -		goto out_free;
> -	}
> -	buf[len] = '\0';	/* guarantee string termination */
> -
>  	/*
>  	 * @of->mutex nests outside active ref and is just to ensure that
>  	 * the ops aren't called concurrently for the same open file.

We probably should update the above comment.

> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index 30faf797c2c3..07c326761671 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -179,6 +179,7 @@ struct kernfs_open_file {
>  	struct mutex		mutex;
>  	int			event;
>  	struct list_head	list;
> +	char			*buf;

Maybe something like ->prealloc_buf is better?

Thanks.

-- 
tejun

  reply	other threads:[~2014-10-05 19:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  2:33 [PATCH 0/2] Allow access to sysfs attributes without mem allocations NeilBrown
2014-09-30  2:33 ` [PATCH 2/2] sysfs/kernfs: make read requests on pre-alloc files use the buffer NeilBrown
2014-10-05 20:02   ` Tejun Heo
2014-09-30  2:33 ` [PATCH 1/2] sysfs - allow attributes to request write buffer be pre-allocated NeilBrown
2014-10-05 19:56   ` Tejun Heo [this message]
2014-10-05 19:46 ` [PATCH 0/2] Allow access to sysfs attributes without mem allocations Tejun Heo

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=20141005195655.GI8549@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --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