linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Becker <jlbec@evilplan.org>
To: Christoph Hellwig <hch@lst.de>
Cc: akpm@linux-foundation.org, nab@linux-iscsi.org,
	pantelis.antoniou@konsulko.com, k.opasiak@samsung.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] configfs: implement binary attributes
Date: Tue, 29 Dec 2015 15:00:30 -0800	[thread overview]
Message-ID: <20151229230029.GC32415@noexit.roam.corp.google.com> (raw)
In-Reply-To: <1450968671-13699-2-git-send-email-hch@lst.de>

On Thu, Dec 24, 2015 at 03:51:10PM +0100, Christoph Hellwig wrote:
> From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> 
> ConfigFS lacked binary attributes up until now. This patch
> introduces support for binary attributes in a somewhat similar
> manner of sysfs binary attributes albeit with changes that
> fit the configfs usage model.
> 
> Problems that configfs binary attributes fix are everything that
> requires a binary blob as part of the configuration of a resource,
> such as bitstream loading for FPGAs, DTBs for dynamically created
> devices etc.

Overall, I really like this addition.

> @@ -423,7 +429,9 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
>  	spin_unlock(&configfs_dirent_lock);
>  
>  	error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
> -				configfs_init_file);
> +				(sd->s_type & CONFIGFS_ITEM_ATTR) ?
> +					configfs_init_file :
> +					configfs_init_bin_file);

BIN_ATTRs are the more uncommon type, at least for now.  I would think
this code should check for special cases and fall back to ITEM_ATTR.  So
reverse it.

	(sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
  		configfs_init_bin_file :
		configfs_init_file

> +static ssize_t
> +configfs_read_bin_file(struct file *file, char __user *buf,
> +		       size_t count, loff_t *ppos)
> +{
> +	struct configfs_buffer *buffer = file->private_data;
> +	struct dentry *dentry = file->f_path.dentry;
> +	struct config_item *item = to_item(dentry->d_parent);
> +	struct configfs_bin_attribute *bin_attr = to_bin_attr(dentry);
> +	ssize_t retval = 0;
> +	ssize_t len = min_t(size_t, count, PAGE_SIZE);
> +
> +	mutex_lock(&buffer->mutex);
> +
> +	/* we don't support switching read/write modes */
> +	if (buffer->write_in_progress) {
> +		retval = -EINVAL;
> +		goto out;
> +	}

These are valid arguments, it's just competing with another operation.
Wouldn't something like EINPROGRESS or ETXTBSY make more sense and be
more informative?  The same for configfs_write_bin_file().

Joel 

-- 

"Soap and education are not as sudden as a massacre, but they are more
 deadly in the long run."
	- Mark Twain


			http://www.jlbec.org/
			jlbec@evilplan.org

  reply	other threads:[~2015-12-29 23:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-24 14:51 a configfs update for 4.5, and the configfs tree question Christoph Hellwig
2015-12-24 14:51 ` [PATCH] configfs: implement binary attributes Christoph Hellwig
2015-12-29 23:00   ` Joel Becker [this message]
2015-12-29 23:26     ` Krzysztof Opasiak
2015-12-30  8:51     ` Pantelis Antoniou
2015-12-29 23:37   ` Krzysztof Opasiak
2015-12-29 23:05 ` a configfs update for 4.5, and the configfs tree question Joel Becker
2016-01-04 11:51   ` Christoph Hellwig
2016-01-04 12:37     ` Fengguang Wu
2016-01-04 20:46     ` Stephen Rothwell
2016-01-05  4:04     ` Joel Becker
2016-01-06 17:31 ` Nicholas A. Bellinger

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=20151229230029.GC32415@noexit.roam.corp.google.com \
    --to=jlbec@evilplan.org \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=k.opasiak@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=pantelis.antoniou@konsulko.com \
    /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).