Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754005AbbL2X0n (ORCPT ); Tue, 29 Dec 2015 18:26:43 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:8952 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753838AbbL2X0k (ORCPT ); Tue, 29 Dec 2015 18:26:40 -0500 X-AuditID: cbfec7f4-f79026d00000418a-94-568316ac62cc Subject: Re: [PATCH] configfs: implement binary attributes To: Christoph Hellwig , akpm@linux-foundation.org, nab@linux-iscsi.org, pantelis.antoniou@konsulko.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <1450968671-13699-1-git-send-email-hch@lst.de> <1450968671-13699-2-git-send-email-hch@lst.de> <20151229230029.GC32415@noexit.roam.corp.google.com> From: Krzysztof Opasiak Message-id: <568316B1.6090800@samsung.com> Date: Wed, 30 Dec 2015 00:26:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-version: 1.0 In-reply-to: <20151229230029.GC32415@noexit.roam.corp.google.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t/xy7prxJrDDG4t1LaYs34Nm8XK1UeZ LPbsPclicXnXHDaLttVnGC2OTlvO4sDm8erAKnaPEzN+s3jc336EyWP3zQY2j8+b5AJYo7hs UlJzMstSi/TtErgydl06xFzwTaji6MPHbA2M7/m6GDk5JARMJHZ+2ccEYYtJXLi3nq2LkYtD SGApo8THpS9YIZznjBLdu5azg1QJC1hJTH33iAUkISKwmVHi4vvbUC2LGCVWXbrI3MXIwcEm oC8xb5coiMkroCXxtVUbpJdFQFVi6dotYHNEBWIkHi/eygpi8woISvyYfI8FxOYUcJT4230e LM4sYCux4P06FghbXmLzmrfMExj5ZyFpmYWkbBaSsgWMzKsYRVNLkwuKk9JzDfWKE3OLS/PS 9ZLzczcxQoL4yw7GxcesDjEKcDAq8fAqiDaHCbEmlhVX5h5ilOBgVhLhvcACFOJNSaysSi3K jy8qzUktPsQozcGiJM47d9f7ECGB9MSS1OzU1ILUIpgsEwenVAOjjqLunBcxRhKNhWHZ0yYI L1/PVPGTu9vvBv/TnPWB52ZMFIvb9vyZlsFFP8XQg4yeRVks/Hd6uqumZF56J7PgtNOBwEnx lUFhfkssVrF/Way3+eyrj+KfN3rqaHkobvGQefs/tDVUdJfn1+nT1A2b2XKnrFitFahqlqg6 ec+CH2kWuRFcE+uVWIozEg21mIuKEwFIeZN3XgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2601 Lines: 75 W dniu 2015-12-30 o 00:00, Joel Becker pisze: > On Thu, Dec 24, 2015 at 03:51:10PM +0100, Christoph Hellwig wrote: >> From: Pantelis Antoniou >> >> 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 > I think that static inline helper can be usefull here to improve readability >> +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 > -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/