Re: [Ocfs2-devel] [PATCH v2 07/10] ocfs2: define integrity_read method

2017-06-28 Thread Christoph Hellwig
should be folded into patch 2.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 00/11 linux-next] super magic values consolidation

2017-05-28 Thread Christoph Hellwig
On Sun, May 21, 2017 at 05:39:47PM +0200, Fabian Frederick wrote:
> This small patchset reorganizes magic.h and fixes filesystems
> which defined locally super magic values.

And what's the point?

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 01/11] fs: try to clone files first in vfs_copy_file_range

2016-12-10 Thread Christoph Hellwig
A clone is a perfectly fine implementation of a file copy, so most
file systems just implement the copy that way.  Instead of duplicating
this logic move it to the VFS.  Currently btrfs and XFS implement copies
the same way as clones and there is no behavior change for them, cifs
only implements clones and grow support for copy_file_range with this
patch.  NFS implements both, so this will allow copy_file_range to work
on servers that only implement CLONE and be lot more efficient on servers
that implements CLONE and COPY.

Signed-off-by: Christoph Hellwig 
---
 fs/btrfs/ctree.h  |3 ---
 fs/btrfs/file.c   |1 -
 fs/btrfs/ioctl.c  |   12 
 fs/read_write.c   |   27 ++-
 fs/xfs/xfs_file.c |   19 ---
 5 files changed, 22 insertions(+), 40 deletions(-)


diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0b8ce2b..05f75a9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3232,9 +3232,6 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct 
inode *inode,
  loff_t pos, size_t write_bytes,
  struct extent_state **cached);
 int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end);
-ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- size_t len, unsigned int flags);
 int btrfs_clone_file_range(struct file *file_in, loff_t pos_in,
   struct file *file_out, loff_t pos_out, u64 len);
 
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 3a14c87..991cc99 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2998,7 +2998,6 @@ const struct file_operations btrfs_file_operations = {
 #ifdef CONFIG_COMPAT
.compat_ioctl   = btrfs_compat_ioctl,
 #endif
-   .copy_file_range = btrfs_copy_file_range,
.clone_file_range = btrfs_clone_file_range,
.dedupe_file_range = btrfs_dedupe_file_range,
 };
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7acbd2c..dab7462 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3980,18 +3980,6 @@ static noinline int btrfs_clone_files(struct file *file, 
struct file *file_src,
return ret;
 }
 
-ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- size_t len, unsigned int flags)
-{
-   ssize_t ret;
-
-   ret = btrfs_clone_files(file_out, file_in, pos_in, len, pos_out);
-   if (ret == 0)
-   ret = len;
-   return ret;
-}
-
 int btrfs_clone_file_range(struct file *src_file, loff_t off,
struct file *dst_file, loff_t destoff, u64 len)
 {
diff --git a/fs/read_write.c b/fs/read_write.c
index 190e0d36..6674a4b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1542,20 +1542,37 @@ ssize_t vfs_copy_file_range(struct file *file_in, 
loff_t pos_in,
if (ret)
return ret;
 
-   ret = -EOPNOTSUPP;
-   if (file_out->f_op->copy_file_range)
+   /*
+* Try cloning first, this is supported by more file systems, and
+* more efficient if both clone and copy are supported (e.g. NFS).
+*/
+   if (file_in->f_op->clone_file_range) {
+   ret = file_in->f_op->clone_file_range(file_in, pos_in,
+   file_out, pos_out, len);
+   if (ret == 0) {
+   ret = len;
+   goto done;
+   }
+   }
+
+   if (file_out->f_op->copy_file_range) {
ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
  pos_out, len, flags);
-   if (ret == -EOPNOTSUPP)
-   ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
-   len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
+   if (ret != -EOPNOTSUPP)
+   goto done;
+   }
 
+   ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
+   len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
+
+done:
if (ret > 0) {
fsnotify_access(file_in);
add_rchar(current, ret);
fsnotify_modify(file_out);
add_wchar(current, ret);
}
+
inc_syscr(current);
inc_syscw(current);
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 6e4f7f9..86ecc9b 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -909,24 +909,6 @@ xfs_file_fallocate(
return error;
 }
 
-STATIC ssize_t
-xfs_file_copy_range(
-   struct file *file_in,
-   loff_t  pos_in,
-   struct file *file_out,
-   loff_t  pos_out,
-   size_t  len,
-   unsigned intflags)
-{
-   int error;
-
-   error = xfs

Re: [Ocfs2-devel] [PATCH v3 0/8] ocfs2: wire up {clone, copy, dedupe}_range

2016-12-10 Thread Christoph Hellwig
On Sat, Dec 10, 2016 at 01:52:57AM +, Al Viro wrote:
> On Fri, Dec 09, 2016 at 12:22:53AM -0800, Christoph Hellwig wrote:
> > On Thu, Dec 08, 2016 at 11:32:13PM -0800, Darrick J. Wong wrote:
> > > It's been a week and nobody's written in any objections.  Andrew, could
> > > this go into linux-next for some soak time?
> > 
> > I'm mostly fine with my series, but I would much prefer if this went
> > on top of my patch to implement the copy -> clone fallback in the core
> > to avoid creating annoying merge conflicts.
> 
> What was the latest of the patch in question?

https://www.spinics.net/lists/linux-fsdevel/msg104745.html

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH v3 0/8] ocfs2: wire up {clone, copy, dedupe}_range

2016-12-09 Thread Christoph Hellwig
On Thu, Dec 08, 2016 at 11:32:13PM -0800, Darrick J. Wong wrote:
> It's been a week and nobody's written in any objections.  Andrew, could
> this go into linux-next for some soak time?

I'm mostly fine with my series, but I would much prefer if this went
on top of my patch to implement the copy -> clone fallback in the core
to avoid creating annoying merge conflicts.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 6/7] ocfs2: implement the VFS clone_range, copy_range, and dedupe_range features

2016-11-25 Thread Christoph Hellwig
> +static ssize_t ocfs2_file_copy_range(struct file *file_in,
> +  loff_t pos_in,
> +  struct file *file_out,
> +  loff_t pos_out,
> +  size_t len,
> +  unsigned int flags)
> +{
> + int error;
> +
> + error = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out,
> +   len, false);
> + if (error)
> + return error;
> + return len;
> +}

Meh, another dummy copy_range implementation, they now officially
outnumber the real ones.  I've had a patch to move this shim to common
code forever, but the complete lack of copy_range testing kept me from
sending it.  I guess I should finally bite the bullet and we should move
it to the front of your series.

> +/* Lock an inode and grab a bh pointing to the inode. */
> +static int ocfs2_reflink_inodes_lock(struct inode *s_inode,
> +  struct buffer_head **bh1,
> +  struct inode *t_inode,
> +  struct buffer_head **bh2)
> +{
> + struct inode *inode1;
> + struct inode *inode2;
> + struct ocfs2_inode_info *oi1;
> + struct ocfs2_inode_info *oi2;
> + bool same_inode = (s_inode == t_inode);
> + int status;
> +
> + /* First grab the VFS and rw locks. */
> + inode1 = s_inode;
> + inode2 = t_inode;
> + if (inode1->i_ino > inode2->i_ino)
> + swap(inode1, inode2);
> +
> + inode_lock(inode1);

For the VFS inode lock this should use lock_two_nondirectories.

> + ret = -ETXTBSY;
> + if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out))
> + goto out_unlock;
> +
> + /* Don't reflink dirs, pipes, sockets... */
> + ret = -EISDIR;
> + if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
> + goto out_unlock;
> + ret = -EINVAL;
> + if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode))
> + goto out_unlock;
> + if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
> + goto out_unlock;
> +
> + /* Are we going all the way to the end? */
> + isize = i_size_read(inode_in);
> + if (isize == 0) {

It seems like most of this should be factored into a
inode_reflink_ok() helper so that it can be shared between
implementations.  Or maybe even inode_prepare_reflink if we can
move the pagecache flushing and extent compare for the clone case
into it as well.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 5/7] ocfs2: don't eat io errors during _dio_end_io_write

2016-11-25 Thread Christoph Hellwig
On Tue, Nov 22, 2016 at 08:36:35PM -0800, Darrick J. Wong wrote:
> ocfs2_dio_end_io_write eats whatever errors may happen,
> which means that write errors do not propagate to userspace.
> Fix that.

Btw, can you also fix up the ocfs2 calling conventions for ->end_io
so that it also does the unlock for the error case in ocfs2_dio_end_io?

I looked at all the inode locking in ocfs2, but couldn't convince me
that either the current code nor the version with the locking changed
is correct..

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [RFC] Should we revert commit "ocfs2: take inode lock in ocfs2_iop_set/get_acl()"? or other ideas?

2016-10-27 Thread Christoph Hellwig
Hi Eric,

I've added linux-fsdevel to the cc list as this should get a bit
broader attention.

On Wed, Oct 19, 2016 at 01:19:40PM +0800, Eric Ren wrote:
> Mostly, we can avoid recursive locking by writing code carefully. However, as
> the deadlock issues have proved out, it's very hard to handle the routines
> that are called directly by vfs. For instance:
> 
> const struct inode_operations ocfs2_file_iops = {
> .permission = ocfs2_permission,
> .get_acl= ocfs2_iop_get_acl,
> .set_acl= ocfs2_iop_set_acl,
> };
> 
> 
> ocfs2_permission() and ocfs2_iop_get/set_acl() both call ocfs2_inode_lock().
> The problem is that the call chain of ocfs2_permission() includes *_acl().

What do you actually protect in ocfs2_permission?  It's a trivial
wrapper around generic_permission which just looks at the VFS inode.

I think the right fix is to remove ocfs2_permission entirely and use
the default VFS implementation.  That both solves your locking problem,
and it will also get you RCU lookup instead of dropping out of
RCU mode all the time.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 37/45] drivers: use req op accessor

2016-08-04 Thread Christoph Hellwig
On Wed, Aug 03, 2016 at 07:30:29PM -0500, Shaun Tancheff wrote:
> I think the translation in loop.c is suspicious here:
> 
> "if use DIO && not (a flush_flag or discard_flag)"
> should translate to:
> "if use DIO && not ((a flush_flag) || op == discard)"
> 
> But in the patch I read:
> "if use DIO && ((not a flush_flag) || op == discard)
> 
> Which would have DIO && discards follow the AIO path?

Indeed.  Sorry for missing out on your patch, I just sent a fix
in reply to Dave's other report earlier which is pretty similar to
yours.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] HEADUP: generic FICLONE ioctl and ->clone_file_range method

2016-03-21 Thread Christoph Hellwig
We made the btrfs clone support generic to add NFS support, and support
the future XFS reflink support.  It looks like ocfs2 could support
these as well, so it would be great to get the clone_file_range method
wired up.  xfstests has over 100 testcases for it, so it should be
easy to verify.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 00/35 v4] separate operations from flags in the bio/request structs

2016-02-29 Thread Christoph Hellwig
Any reason you've dropped my ACK for the previous version?

Jens, is this something you're fine with?  Would be great to figure
out a way to get this into 4.6.  There's probably going to be
plenty of conflicts, so having some sort of stable base tree
would be nice..

(Talking about conflicts, seems like the block for-linus and for-next
trees already conflict quite a bit..)

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH] configfs: switch ->default groups to a linked list

2016-02-28 Thread Christoph Hellwig
On Sun, Feb 28, 2016 at 12:58:42PM +0200, Sagi Grimberg wrote:
>> -As a consequence of this, default_groups cannot be removed directly via
>> +As a consequence of this, default groups cannot be removed directly via
>>   rmdir(2).  They also are not considered when rmdir(2) on the parent
>>   group is checking for children.
>>
>
> What's changed here?

I removed the underscore in default_groups - while we still have
a member of that name it's not exposed directly anymore, so I'd rather
not have the documentation refer to it.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH] configfs: switch ->default groups to a linked list

2016-02-26 Thread Christoph Hellwig
Replace the current NULL-terminated array of default groups with a linked
list.  This gets rid of lots of nasty code to size and/or dynamically
allocate the array.

While we're at it also provide a conveniant helper to remove the default
groups.

Signed-off-by: Christoph Hellwig 
---
 Documentation/filesystems/configfs/configfs.txt |  11 +-
 drivers/infiniband/core/cma_configfs.c  |  31 ++--
 drivers/target/iscsi/iscsi_target_configfs.c|  75 +++--
 drivers/target/target_core_configfs.c   | 203 +---
 drivers/target/target_core_fabric_configfs.c| 194 ++
 drivers/target/target_core_internal.h   |   1 -
 drivers/target/target_core_stat.c   |  41 ++---
 drivers/usb/gadget/configfs.c   |  36 ++---
 drivers/usb/gadget/function/f_mass_storage.c|   6 +-
 drivers/usb/gadget/function/f_rndis.c   |   1 -
 drivers/usb/gadget/function/uvc_configfs.c  | 198 +--
 fs/configfs/dir.c   |  44 +++--
 fs/configfs/item.c  |   1 +
 fs/dlm/config.c |  38 +
 fs/ocfs2/cluster/nodemanager.c  |  22 +--
 include/linux/configfs.h|  11 +-
 include/target/target_core_base.h   |   3 -
 17 files changed, 284 insertions(+), 632 deletions(-)

diff --git a/Documentation/filesystems/configfs/configfs.txt 
b/Documentation/filesystems/configfs/configfs.txt
index e5fe521..8ec9136 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -250,7 +250,8 @@ child item.
struct config_item  cg_item;
struct list_headcg_children;
struct configfs_subsystem   *cg_subsys;
-   struct config_group **default_groups;
+   struct list_headdefault_groups;
+   struct list_headgroup_entry;
};
 
void config_group_init(struct config_group *group);
@@ -420,15 +421,15 @@ These automatic subgroups, or default groups, do not 
preclude other
 children of the parent group.  If ct_group_ops->make_group() exists,
 other child groups can be created on the parent group directly.
 
-A configfs subsystem specifies default groups by filling in the
-NULL-terminated array default_groups on the config_group structure.
-Each group in that array is populated in the configfs tree at the same
+A configfs subsystem specifies default groups by adding them using the
+configfs_add_default_group() function to the parent config_group
+structure.  Each added group is populated in the configfs tree at the same
 time as the parent group.  Similarly, they are removed at the same time
 as the parent.  No extra notification is provided.  When a ->drop_item()
 method call notifies the subsystem the parent group is going away, it
 also means every default group child associated with that parent group.
 
-As a consequence of this, default_groups cannot be removed directly via
+As a consequence of this, default groups cannot be removed directly via
 rmdir(2).  They also are not considered when rmdir(2) on the parent
 group is checking for children.
 
diff --git a/drivers/infiniband/core/cma_configfs.c 
b/drivers/infiniband/core/cma_configfs.c
index 18b112a..41573df 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -49,8 +49,6 @@ struct cma_dev_group {
charname[IB_DEVICE_NAME_MAX];
struct config_group device_group;
struct config_group ports_group;
-   struct config_group *default_dev_group[2];
-   struct config_group **default_ports_group;
struct cma_dev_port_group   *ports;
 };
 
@@ -158,7 +156,6 @@ static int make_cma_ports(struct cma_dev_group 
*cma_dev_group,
unsigned int i;
unsigned int ports_num;
struct cma_dev_port_group *ports;
-   struct config_group **ports_group;
int err;
 
ibdev = cma_get_ib_dev(cma_dev);
@@ -169,9 +166,8 @@ static int make_cma_ports(struct cma_dev_group 
*cma_dev_group,
ports_num = ibdev->phys_port_cnt;
ports = kcalloc(ports_num, sizeof(*cma_dev_group->ports),
GFP_KERNEL);
-   ports_group = kcalloc(ports_num + 1, sizeof(*ports_group), GFP_KERNEL);
 
-   if (!ports || !ports_group) {
+   if (!ports) {
err = -ENOMEM;
goto free;
}
@@ -185,18 +181,16 @@ static int make_cma_ports(struct cma_dev_group 
*cma_dev_group,
config_group_init_type_name(&ports[i].group,
port_str,
&cma_port_group_type);
-   ports_g

Re: [Ocfs2-devel] [PATCH 2/3] xfs: don't use ioends for direct write completions

2016-02-08 Thread Christoph Hellwig
On Mon, Feb 08, 2016 at 08:16:44PM +1100, Dave Chinner wrote:
> I can't tell if you are saying what I've done is fine if the
> xfs-dio-fix-4.6 branch is stable (so others can pull it) or whether
> it should be in some other tree. Can you clarify, Christoph?

What you are doing is fine, thanks!

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 2/3] xfs: don't use ioends for direct write completions

2016-02-07 Thread Christoph Hellwig
On Mon, Feb 08, 2016 at 05:17:31PM +1100, Dave Chinner wrote:
> Right now this series is in a stable branch in the XFS tree:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git 
> xfs-dio-fix-4.6
> 
> If you want to push it through some other tree, please let me know
> when/where it is committed so I can rebuild the XFS for-next branch
> appropriately from a stable commit/branch...

That's how I think it should be handled.  This would also allow the
ext4 and ocfs2 maintainers to depend on the stable branch to clean
up their direct I/O completion handling in this merge window if they
want to.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 1/3] direct-io: always call ->end_io if non-NULL

2016-02-03 Thread Christoph Hellwig
On Wed, Feb 03, 2016 at 11:55:31AM -0800, Darrick J. Wong wrote:
> This will have the effect of a later error superseding an earlier error.  I'm
> under the impression that code should generally preserve the first error, 
> since
> some side effect of that probably caused the rest of the errors.
> 
> That said, my guess is that 95% of the time err is set, retval and err will
> both be -EIO anyway.  I'm not particularly passionate about whether or not we
> preserve the first error code.

This leaves the option to the file system to pass the value through
or not.  Note that ret before the call will usually have the positive
number of bytes written, so checking if it's 'set' wouldn't be enough
even if adding some special casing in the callers.

> > +static int ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
> > ssize_t size, void *private)
> >  {
> >  ext4_io_end_t *io_end = iocb->private;
> >  
> > +   if (size <= 0)
> > +   return 0;
> 
> This leaks the ext4_io_end_t, if there was one.  Granted, that only happens
> during an AIO DIO to an unwritten extent, but in any case I suggest removing
> this hunk and...

It's the same behavior as before - and if you look at ext4_ext_direct_IO
it seems to expect this and works around it.

> > +   if (bytes <= 0)
> > +   return 0;
> > +
> 
> I suspect we still need to unlock the mutexes later on in this function.
> 
> > /* this io's submitter should not have unlocked this before we could */
> > BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
> >  
> > @@ -644,6 +647,8 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
> > level = ocfs2_iocb_rw_locked_level(iocb);
> > ocfs2_rw_unlock(inode, level);
> > }
> 
> Do we need to still have an accurate value for bytes the conditional above
> even if the IO errored out?  

Again, no changes to the old behavior.  ocfs has some magic stuffed
in iocb->private to deal with the locked state of an iocb, and while
I don't fully understand it I suspect it's to handle the existing
odd ->end_io calling conventions.  Cleaning this up would be nice,
but let's keep that a separate patch.

> > struct kiocb*iocb,
> > loff_t  offset,
> > @@ -1655,15 +1655,19 @@ xfs_end_io_direct_write(
> > struct inode*inode = file_inode(iocb->ki_filp);
> > struct xfs_ioend*ioend = private;
> >  
> > +   if (size <= 0)
> > +   return 0;
> 
> Same thing here, I think we can end up leaking the ioend.

This keeps the existing behavior.  But either way, at least for
XFS all this will be properly fixed in the next patch anyway.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 2/3] xfs: don't use ioends for direct write completions

2016-02-03 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

We only need to communicate two bits of information to the direct I/O
completion handler:

 (1) do we need to convert any unwritten extents in the range
 (2) do we need to check if we need to update the inode size based
 on the range passed to the completion handler

We can use the private data passed to the get_block handler and the
completion handler as a simple bitmask to communicate this information
instead of the current complicated infrastructure reusing the ioends
from the buffer I/O path, and thus avoiding a memory allocation and
a context switch for any non-trivial direct write.  As a nice side
effect we also decouple the direct I/O path implementation from that
of the buffered I/O path.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Brian Foster 
---
 fs/xfs/xfs_aops.c  | 216 ++---
 fs/xfs/xfs_trace.h |   9 +--
 2 files changed, 75 insertions(+), 150 deletions(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 295aaff..f008a4f 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -36,6 +36,10 @@
 #include 
 #include 
 
+/* flags for direct write completions */
+#define XFS_DIO_FLAG_UNWRITTEN (1 << 0)
+#define XFS_DIO_FLAG_APPEND(1 << 1)
+
 void
 xfs_count_page_state(
struct page *page,
@@ -1238,27 +1242,8 @@ xfs_vm_releasepage(
 }
 
 /*
- * When we map a DIO buffer, we may need to attach an ioend that describes the
- * type of write IO we are doing. This passes to the completion function the
- * operations it needs to perform. If the mapping is for an overwrite wholly
- * within the EOF then we don't need an ioend and so we don't allocate one.
- * This avoids the unnecessary overhead of allocating and freeing ioends for
- * workloads that don't require transactions on IO completion.
- *
- * If we get multiple mappings in a single IO, we might be mapping different
- * types. But because the direct IO can only have a single private pointer, we
- * need to ensure that:
- *
- * a) i) the ioend spans the entire region of unwritten mappings; or
- *ii) the ioend spans all the mappings that cross or are beyond EOF; and
- * b) if it contains unwritten extents, it is *permanently* marked as such
- *
- * We could do this by chaining ioends like buffered IO does, but we only
- * actually get one IO completion callback from the direct IO, and that spans
- * the entire IO regardless of how many mappings and IOs are needed to complete
- * the DIO. There is only going to be one reference to the ioend and its life
- * cycle is constrained by the DIO completion code. hence we don't need
- * reference counting here.
+ * When we map a DIO buffer, we may need to pass flags to
+ * xfs_end_io_direct_write to tell it what kind of write IO we are doing.
  *
  * Note that for DIO, an IO to the highest supported file block offset (i.e.
  * 2^63 - 1FSB bytes) will result in the offset + count overflowing a signed 64
@@ -1266,68 +1251,26 @@ xfs_vm_releasepage(
  * extending the file size. We won't know for sure until IO completion is run
  * and the actual max write offset is communicated to the IO completion
  * routine.
- *
- * For DAX page faults, we are preparing to never see unwritten extents here,
- * nor should we ever extend the inode size. Hence we will soon have nothing to
- * do here for this case, ensuring we don't have to provide an IO completion
- * callback to free an ioend that we don't actually need for a fault into the
- * page at offset (2^63 - 1FSB) bytes.
  */
-
 static void
 xfs_map_direct(
struct inode*inode,
struct buffer_head  *bh_result,
struct xfs_bmbt_irec*imap,
-   xfs_off_t   offset,
-   booldax_fault)
+   xfs_off_t   offset)
 {
-   struct xfs_ioend*ioend;
+   uintptr_t   *flags = (uintptr_t *)&bh_result->b_private;
xfs_off_t   size = bh_result->b_size;
-   int type;
-
-   if (ISUNWRITTEN(imap))
-   type = XFS_IO_UNWRITTEN;
-   else
-   type = XFS_IO_OVERWRITE;
-
-   trace_xfs_gbmap_direct(XFS_I(inode), offset, size, type, imap);
-
-   if (dax_fault) {
-   ASSERT(type == XFS_IO_OVERWRITE);
-   trace_xfs_gbmap_direct_none(XFS_I(inode), offset, size, type,
-   imap);
-   return;
-   }
 
-   if (bh_result->b_private) {
-   ioend = bh_result->b_private;
-   ASSERT(ioend->io_size > 0);
-   ASSERT(offset >= ioend->io_offset);
-   if (offset + size > ioend->io_offset + ioend->io_size)
-   ioend->io_size = offset - ioend->io_offset + size;
-
-   if (type == XFS_IO_UNWR

[Ocfs2-devel] [PATCH 3/3] xfs: fold xfs_vm_do_dio into xfs_vm_direct_IO

2016-02-03 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

Signed-off-by: Christoph Hellwig 
Reviewed-by: Brian Foster 
---
 fs/xfs/xfs_aops.c | 36 ++--
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index f008a4f..8163910 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1596,38 +1596,30 @@ xfs_end_io_direct_write(
return error;
 }
 
-static inline ssize_t
-xfs_vm_do_dio(
-   struct inode*inode,
+STATIC ssize_t
+xfs_vm_direct_IO(
struct kiocb*iocb,
struct iov_iter *iter,
-   loff_t  offset,
-   dio_iodone_tendio,
-   int flags)
+   loff_t  offset)
 {
+   struct inode*inode = iocb->ki_filp->f_mapping->host;
+   dio_iodone_t*endio = NULL;
+   int flags = 0;
struct block_device *bdev;
 
-   if (IS_DAX(inode))
+   if (iov_iter_rw(iter) == WRITE) {
+   endio = xfs_end_io_direct_write;
+   flags = DIO_ASYNC_EXTEND;
+   }
+
+   if (IS_DAX(inode)) {
return dax_do_io(iocb, inode, iter, offset,
 xfs_get_blocks_direct, endio, 0);
+   }
 
bdev = xfs_find_bdev_for_inode(inode);
return  __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
-xfs_get_blocks_direct, endio, NULL, flags);
-}
-
-STATIC ssize_t
-xfs_vm_direct_IO(
-   struct kiocb*iocb,
-   struct iov_iter *iter,
-   loff_t  offset)
-{
-   struct inode*inode = iocb->ki_filp->f_mapping->host;
-
-   if (iov_iter_rw(iter) == WRITE)
-   return xfs_vm_do_dio(inode, iocb, iter, offset,
-xfs_end_io_direct_write, DIO_ASYNC_EXTEND);
-   return xfs_vm_do_dio(inode, iocb, iter, offset, NULL, 0);
+   xfs_get_blocks_direct, endio, NULL, flags);
 }
 
 /*
-- 
2.1.4


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 1/3] direct-io: always call ->end_io if non-NULL

2016-02-03 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

This way we can pass back errors to the file system, and allow for
cleanup required for all direct I/O invocations.

Also allow the ->end_io handlers to return errors on their own, so that
I/O completion errors can be passed on to the callers.

Signed-off-by: Christoph Hellwig 
---
 fs/dax.c   |  9 +++--
 fs/direct-io.c |  9 +++--
 fs/ext4/inode.c|  9 +++--
 fs/ocfs2/aops.c|  7 ++-
 fs/xfs/xfs_aops.c  | 13 +++--
 include/linux/fs.h |  2 +-
 6 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 4fd6b0c..e38b2c5 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -267,8 +267,13 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
inode_unlock(inode);
 
-   if ((retval > 0) && end_io)
-   end_io(iocb, pos, retval, bh.b_private);
+   if (end_io) {
+   int err;
+
+   err = end_io(iocb, pos, retval, bh.b_private);
+   if (err)
+   retval = err;
+   }
 
if (!(flags & DIO_SKIP_DIO_COUNT))
inode_dio_end(inode);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1b2f7ff..9c6f885 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -253,8 +253,13 @@ static ssize_t dio_complete(struct dio *dio, loff_t 
offset, ssize_t ret,
if (ret == 0)
ret = transferred;
 
-   if (dio->end_io && dio->result)
-   dio->end_io(dio->iocb, offset, transferred, dio->private);
+   if (dio->end_io) {
+   int err;
+
+   err = dio->end_io(dio->iocb, offset, ret, dio->private);
+   if (err)
+   ret = err;
+   }
 
if (!(dio->flags & DIO_SKIP_DIO_COUNT))
inode_dio_end(dio->inode);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 83bc8bf..9db04dd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3161,14 +3161,17 @@ out:
 }
 #endif
 
-static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
+static int ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
ssize_t size, void *private)
 {
 ext4_io_end_t *io_end = iocb->private;
 
+   if (size <= 0)
+   return 0;
+
/* if not async direct IO just return */
if (!io_end)
-   return;
+   return 0;
 
ext_debug("ext4_end_io_dio(): io_end 0x%p "
  "for inode %lu, iocb 0x%p, offset %llu, size %zd\n",
@@ -3179,6 +3182,8 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t 
offset,
io_end->offset = offset;
io_end->size = size;
ext4_put_io_end(io_end);
+
+   return 0;
 }
 
 /*
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 794fd15..5dcc5f5 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -620,7 +620,7 @@ bail:
  * particularly interested in the aio/dio case.  We use the rw_lock DLM lock
  * to protect io on one node from truncation on another.
  */
-static void ocfs2_dio_end_io(struct kiocb *iocb,
+static int ocfs2_dio_end_io(struct kiocb *iocb,
 loff_t offset,
 ssize_t bytes,
 void *private)
@@ -628,6 +628,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
struct inode *inode = file_inode(iocb->ki_filp);
int level;
 
+   if (bytes <= 0)
+   return 0;
+
/* this io's submitter should not have unlocked this before we could */
BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
 
@@ -644,6 +647,8 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
level = ocfs2_iocb_rw_locked_level(iocb);
ocfs2_rw_unlock(inode, level);
}
+
+   return 0;
 }
 
 static int ocfs2_releasepage(struct page *page, gfp_t wait)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 379c089..295aaff 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1645,7 +1645,7 @@ out_end_io:
  * case the completion can be called in interrupt context, whereas if we have 
an
  * ioend we will always be called in task context (i.e. from a workqueue).
  */
-STATIC void
+STATIC int
 xfs_end_io_direct_write(
struct kiocb*iocb,
loff_t  offset,
@@ -1655,15 +1655,19 @@ xfs_end_io_direct_write(
struct inode*inode = file_inode(iocb->ki_filp);
struct xfs_ioend*ioend = private;
 
+   if (size <= 0)
+   return 0;
+
trace_xfs_gbmap_direct_endio(XFS_I(inode), offset, size,
 ioend ? ioend->io_type : 0, NULL);
 
if (!ioend) {
ASSERT(offset + size <= i_size_read(inode));
-   return;
+   return 0;
  

[Ocfs2-devel] vfs/xfs: directio updates to ease COW handling V2

2016-02-03 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

The first patch ensures ->end_io is always called for direct I/O requests
that pass it in, even if there was a zero length write, or if an error
occured.  The existing users have been updated to ignore it, but XFS
will make use of it in the future, and a comment in ext4 suggests it
might be useful for it as well.

The other two simplify the XFS direct I/O code.

Changes since V1:
 - allow ->end_io to return errors
 - a comment spelling fix



___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 1/3] direct-io: always call ->end_io if non-NULL

2016-02-03 Thread Christoph Hellwig
> > -   if (dio->end_io && dio->result)
> > -   dio->end_io(dio->iocb, offset, transferred, dio->private);
> > +   if (dio->end_io)
> > +   dio->end_io(dio->iocb, offset, ret, dio->private);
> 
> Could we make end_io return an int so that errors during completion can be
> stuffed into ret to be picked up by whatever's calling directio?  Something
> like this:
> 
> if (dio->end_io) {
>   int ret2;
> 
>   ret2 = dio->end_io(dio->iocb, offset, ret, dio->private);
>   if (ret2 && !ret)
>   ret = ret2;
> }
> 
> That way I can capture IO errors during the CoW remapping step and pass them 
> to
> userland either via dio_complete()'s return value or through ki_complete.
> 
> (If ret itself is an error code then obviously we don't bother with the
> post-CoW remap.)

Should be doable, I'll respin it with that change.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] VFS/XFS: directio updates to ease COW handling

2016-02-02 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

The first patch ensures ->end_io is always called for direct I/O requests
that pass it in, even if there was a zero length write, or if an error
occured.  The existing users have been updated to ignore it, but XFS
will make use of it in the future, and a comment in ext4 suggests it
might be useful for it as well.

The other two simplify the XFS direct I/O code.


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 1/3] direct-io: always call ->end_io if non-NULL

2016-02-02 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

This way we can pass back errors to the file system, and allow for
cleanup required for all direct I/O invocations.

Signed-off-by: Christoph Hellwig 
---
 fs/dax.c  | 2 +-
 fs/direct-io.c| 4 ++--
 fs/ext4/inode.c   | 3 +++
 fs/ocfs2/aops.c   | 3 +++
 fs/xfs/xfs_aops.c | 3 +++
 5 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 4fd6b0c..e47d1ba 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -267,7 +267,7 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
inode_unlock(inode);
 
-   if ((retval > 0) && end_io)
+   if (end_io)
end_io(iocb, pos, retval, bh.b_private);
 
if (!(flags & DIO_SKIP_DIO_COUNT))
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1b2f7ff..ead7ac1 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -253,8 +253,8 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, 
ssize_t ret,
if (ret == 0)
ret = transferred;
 
-   if (dio->end_io && dio->result)
-   dio->end_io(dio->iocb, offset, transferred, dio->private);
+   if (dio->end_io)
+   dio->end_io(dio->iocb, offset, ret, dio->private);
 
if (!(dio->flags & DIO_SKIP_DIO_COUNT))
inode_dio_end(dio->inode);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 83bc8bf..d04555b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3166,6 +3166,9 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t 
offset,
 {
 ext4_io_end_t *io_end = iocb->private;
 
+   if (size <= 0)
+   return;
+
/* if not async direct IO just return */
if (!io_end)
return;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 794fd15..1eeb804 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -628,6 +628,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
struct inode *inode = file_inode(iocb->ki_filp);
int level;
 
+   if (bytes <= 0)
+   return;
+
/* this io's submitter should not have unlocked this before we could */
BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
 
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 379c089..c318e9f 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1655,6 +1655,9 @@ xfs_end_io_direct_write(
struct inode*inode = file_inode(iocb->ki_filp);
struct xfs_ioend*ioend = private;
 
+   if (size <= 0)
+   return;
+
trace_xfs_gbmap_direct_endio(XFS_I(inode), offset, size,
 ioend ? ioend->io_type : 0, NULL);
 
-- 
2.1.4


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 2/3] xfs: don't use ioends for direct write completions

2016-02-02 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

We only need to communicate two bits of information to the direct I/O
completion handler:

 (1) do we need to convert any unwritten extents in the range
 (2) do we need to check if we need to update the inode size based
 on the range passed to the completion handler

We can use the private data passed to the get_block handler and the
completion handler as a simple bitmask to communicate this information
instead of the current complicated infrastructure reusing the ioends
from the buffer I/O path, and thus avoiding a memory allocation and
a context switch for any non-trivial direct write.  As a nice side
effect we also decouple the direct I/O path implementation from that
of the buffered I/O path.

Signed-off-by: Christoph Hellwig 
---
 fs/xfs/xfs_aops.c  | 216 ++---
 fs/xfs/xfs_trace.h |   9 +--
 2 files changed, 77 insertions(+), 148 deletions(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index c318e9f..f6b08ea 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -36,6 +36,10 @@
 #include 
 #include 
 
+/* flags for direct write completions */
+#define XFS_DIO_FLAG_UNWRITTEN (1 << 0)
+#define XFS_DIO_FLAG_APPEND(1 << 1)
+
 void
 xfs_count_page_state(
struct page *page,
@@ -1238,27 +1242,8 @@ xfs_vm_releasepage(
 }
 
 /*
- * When we map a DIO buffer, we may need to attach an ioend that describes the
- * type of write IO we are doing. This passes to the completion function the
- * operations it needs to perform. If the mapping is for an overwrite wholly
- * within the EOF then we don't need an ioend and so we don't allocate one.
- * This avoids the unnecessary overhead of allocating and freeing ioends for
- * workloads that don't require transactions on IO completion.
- *
- * If we get multiple mappings in a single IO, we might be mapping different
- * types. But because the direct IO can only have a single private pointer, we
- * need to ensure that:
- *
- * a) i) the ioend spans the entire region of unwritten mappings; or
- *ii) the ioend spans all the mappings that cross or are beyond EOF; and
- * b) if it contains unwritten extents, it is *permanently* marked as such
- *
- * We could do this by chaining ioends like buffered IO does, but we only
- * actually get one IO completion callback from the direct IO, and that spans
- * the entire IO regardless of how many mappings and IOs are needed to complete
- * the DIO. There is only going to be one reference to the ioend and its life
- * cycle is constrained by the DIO completion code. hence we don't need
- * reference counting here.
+ * When we map a DIO buffer, we may need to pass flags to
+ * xfs_end_io_direct_write to tell it what kind of write IO we are doing.
  *
  * Note that for DIO, an IO to the highest supported file block offset (i.e.
  * 2^63 - 1FSB bytes) will result in the offset + count overflowing a signed 64
@@ -1266,68 +1251,26 @@ xfs_vm_releasepage(
  * extending the file size. We won't know for sure until IO completion is run
  * and the actual max write offset is communicated to the IO completion
  * routine.
- *
- * For DAX page faults, we are preparing to never see unwritten extents here,
- * nor should we ever extend the inode size. Hence we will soon have nothing to
- * do here for this case, ensuring we don't have to provide an IO completion
- * callback to free an ioend that we don't actually need for a fault into the
- * page at offset (2^63 - 1FSB) bytes.
  */
-
 static void
 xfs_map_direct(
struct inode*inode,
struct buffer_head  *bh_result,
struct xfs_bmbt_irec*imap,
-   xfs_off_t   offset,
-   booldax_fault)
+   xfs_off_t   offset)
 {
-   struct xfs_ioend*ioend;
+   uintptr_t   *flags = (uintptr_t *)&bh_result->b_private;
xfs_off_t   size = bh_result->b_size;
-   int type;
-
-   if (ISUNWRITTEN(imap))
-   type = XFS_IO_UNWRITTEN;
-   else
-   type = XFS_IO_OVERWRITE;
-
-   trace_xfs_gbmap_direct(XFS_I(inode), offset, size, type, imap);
-
-   if (dax_fault) {
-   ASSERT(type == XFS_IO_OVERWRITE);
-   trace_xfs_gbmap_direct_none(XFS_I(inode), offset, size, type,
-   imap);
-   return;
-   }
 
-   if (bh_result->b_private) {
-   ioend = bh_result->b_private;
-   ASSERT(ioend->io_size > 0);
-   ASSERT(offset >= ioend->io_offset);
-   if (offset + size > ioend->io_offset + ioend->io_size)
-   ioend->io_size = offset - ioend->io_offset + size;
-
-   if (type == XFS_IO_UNWRITTEN && type != ioend->io_type)
-   i

[Ocfs2-devel] [PATCH 3/3] xfs: fold xfs_vm_do_dio into xfs_vm_direct_IO

2016-02-02 Thread Christoph Hellwig
See http://www.infradead.org/rpr.html

Signed-off-by: Christoph Hellwig 
---
 fs/xfs/xfs_aops.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index f6b08ea..e3cb7f8 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1599,41 +1599,30 @@ xfs_end_io_direct_write(
}
 }
 
-static inline ssize_t
-xfs_vm_do_dio(
-   struct inode*inode,
+STATIC ssize_t
+xfs_vm_direct_IO(
struct kiocb*iocb,
struct iov_iter *iter,
-   loff_t  offset,
-   void(*endio)(struct kiocb   *iocb,
-loff_t offset,
-ssize_tsize,
-void   *private),
-   int flags)
+   loff_t  offset)
 {
+   struct inode*inode = iocb->ki_filp->f_mapping->host;
+   dio_iodone_t*endio = NULL;
+   int flags = 0;
struct block_device *bdev;
 
-   if (IS_DAX(inode))
+   if (iov_iter_rw(iter) == WRITE) {
+   endio = xfs_end_io_direct_write;
+   flags = DIO_ASYNC_EXTEND;
+   }
+
+   if (IS_DAX(inode)) {
return dax_do_io(iocb, inode, iter, offset,
 xfs_get_blocks_direct, endio, 0);
+   }
 
bdev = xfs_find_bdev_for_inode(inode);
return  __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
-xfs_get_blocks_direct, endio, NULL, flags);
-}
-
-STATIC ssize_t
-xfs_vm_direct_IO(
-   struct kiocb*iocb,
-   struct iov_iter *iter,
-   loff_t  offset)
-{
-   struct inode*inode = iocb->ki_filp->f_mapping->host;
-
-   if (iov_iter_rw(iter) == WRITE)
-   return xfs_vm_do_dio(inode, iocb, iter, offset,
-xfs_end_io_direct_write, DIO_ASYNC_EXTEND);
-   return xfs_vm_do_dio(inode, iocb, iter, offset, NULL, 0);
+   xfs_get_blocks_direct, endio, NULL, flags);
 }
 
 /*
-- 
2.1.4


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 00/35 v3] eparate operations from flags in the bio/request structs

2016-01-18 Thread Christoph Hellwig
The whole sries looks fine to me:

Reviewed-by: Christoph Hellwig 

There are a few pieces of future work on top of this I'd rather see
sooner than later though:

 - use REQ_OP_FLUSH for all empty flushes, including those at the bio
   level.
 - merge the req->cmd_type values into req->op.  Right now that's
   basically only a new REQ_OP_BLOCK_PC (or better REQ_OP_SCSI while
   we're at it) and a REQ_OP_DRV_PRIV as the last value.
 - drop as many of the crazy defines based on REQ_* in fs.h (e.g.
   (READ_SYNC, WRITE_SYNC, WRITE_ODIRECT, WRITE_FLUSH, WRITE_FUA,
   WRITE_FLUSH_FUA, RW_MASK, RWA_MASK)

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields

2016-01-09 Thread Christoph Hellwig
On Sat, Jan 09, 2016 at 07:21:12PM -0600, Mike Christie wrote:
> Oh yeah, to answer the second part of your question, REQ_OP_FLUSH is
> only a flush operation like what request_fn drivers wanted.

And that's the odd part that trips me up.

> 
> REQ_PREFLUSH can be set with a REQ_OP_WRITE bio when filesystems want to
> do both.
> 
> There is then the case where filesystems and blkdev_issue_flush could
> just want to request a flush. I left them as a REQ_PREFLUSH with
> REQ_OP_WRITE set, so there would be a single code path.

But the pure flush without data transfer case is pretty different,
so it seems rather odd to handle it like that.  But I suspec we could
just fix that up later.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields

2016-01-09 Thread Christoph Hellwig
On Sat, Jan 09, 2016 at 06:56:14PM -0600, Mike Christie wrote:
> I did not change the flush related code until the last patches. I added
> REQ_OP_FLUSH in patch:

Oh, I missed that.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 26/35] block: set op to REQ_OP

2016-01-09 Thread Christoph Hellwig
> @@ -1149,10 +1151,12 @@ static struct request *__get_request(struct 
> request_list *rl, int rw_flags,
>  
>   blk_rq_init(q, rq);
>   blk_rq_set_rl(rq, rl);
> - rq->cmd_flags = rw_flags | REQ_ALLOCED;
> + /* tmp compat - allow users to check either one for the op */
> + rq->cmd_flags = op | op_flags | REQ_ALLOCED;

This one is still left after the whole series is applied, seems like
the hunk to remove it again got lost somewhere.


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields

2016-01-09 Thread Christoph Hellwig
Seems like this is missing REQ_OP_FLUSH, which still hides as a write?


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 01/35] block/fs/drivers: remove rw argument from submit_bio

2016-01-09 Thread Christoph Hellwig
On Tue, Jan 05, 2016 at 02:53:04PM -0600, mchri...@redhat.com wrote:
> From: Mike Christie 
> 
> This has callers of submit_bio/submit_bio_wait set the bio->bi_rw
> instead of passing it in. This makes that use the same as
> generic_make_request and how we set the other bio fields.
> 
> Signed-off-by: Mike Christie 
> ---
>  block/bio.c |  7 +++
>  block/blk-core.c| 11 ---
>  block/blk-flush.c   |  3 ++-
>  block/blk-lib.c |  9 ++---
>  drivers/block/drbd/drbd_actlog.c|  2 +-
>  drivers/block/drbd/drbd_bitmap.c|  4 ++--
>  drivers/block/floppy.c  |  3 ++-
>  drivers/block/xen-blkback/blkback.c |  4 +++-
>  drivers/block/xen-blkfront.c|  4 ++--
>  drivers/md/bcache/debug.c   |  6 --
>  drivers/md/bcache/journal.c |  2 +-
>  drivers/md/bcache/super.c   |  4 ++--
>  drivers/md/dm-bufio.c   |  3 ++-
>  drivers/md/dm-io.c  |  3 ++-
>  drivers/md/dm-log-writes.c  |  9 ++---
>  drivers/md/dm-thin.c|  3 ++-
>  drivers/md/md.c | 10 +++---
>  drivers/md/raid1.c  |  3 ++-
>  drivers/md/raid10.c |  4 +++-
>  drivers/md/raid5-cache.c|  7 ---
>  drivers/target/target_core_iblock.c | 24 +---
>  fs/btrfs/check-integrity.c  | 18 ++
>  fs/btrfs/check-integrity.h  |  4 ++--
>  fs/btrfs/disk-io.c  |  3 ++-
>  fs/btrfs/extent_io.c|  7 ---
>  fs/btrfs/raid56.c   | 16 +++-
>  fs/btrfs/scrub.c| 16 +++-
>  fs/btrfs/volumes.c  | 14 +++---
>  fs/buffer.c |  3 ++-
>  fs/direct-io.c  |  3 ++-
>  fs/ext4/crypto.c|  3 ++-
>  fs/ext4/page-io.c   |  3 ++-
>  fs/ext4/readpage.c  |  9 +
>  fs/f2fs/data.c  | 13 -
>  fs/f2fs/segment.c   |  6 --
>  fs/gfs2/lops.c  |  3 ++-
>  fs/gfs2/meta_io.c   |  3 ++-
>  fs/gfs2/ops_fstype.c|  3 ++-
>  fs/hfsplus/wrapper.c|  3 ++-
>  fs/jfs/jfs_logmgr.c |  6 --
>  fs/jfs/jfs_metapage.c   | 10 ++
>  fs/logfs/dev_bdev.c | 15 ++-
>  fs/mpage.c  |  3 ++-
>  fs/nfs/blocklayout/blocklayout.c| 22 --
>  fs/nilfs2/segbuf.c  |  3 ++-
>  fs/ocfs2/cluster/heartbeat.c| 12 +++-
>  fs/xfs/xfs_aops.c   |  3 ++-
>  fs/xfs/xfs_buf.c|  4 ++--
>  include/linux/bio.h |  2 +-
>  include/linux/fs.h  |  2 +-
>  kernel/power/swap.c |  5 +++--
>  mm/page_io.c| 10 ++
>  52 files changed, 211 insertions(+), 141 deletions(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index dbabd48..921112b 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -859,21 +859,20 @@ static void submit_bio_wait_endio(struct bio *bio)
>  
>  /**
>   * submit_bio_wait - submit a bio, and wait until it completes
> - * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
>   * @bio: The &struct bio which describes the I/O
>   *
>   * Simple wrapper around submit_bio(). Returns 0 on success, or the error 
> from
>   * bio_endio() on failure.
>   */
> -int submit_bio_wait(int rw, struct bio *bio)
> +int submit_bio_wait(struct bio *bio)
>  {
>   struct submit_bio_ret ret;
>  
> - rw |= REQ_SYNC;
>   init_completion(&ret.event);
>   bio->bi_private = &ret;
>   bio->bi_end_io = submit_bio_wait_endio;
> - submit_bio(rw, bio);
> + bio->bi_rw |= REQ_SYNC;
> + submit_bio(bio);
>   wait_for_completion(&ret.event);
>  
>   return ret.error;
> diff --git a/block/blk-core.c b/block/blk-core.c
> index ab51685..9b887e3 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -2092,7 +2092,6 @@ EXPORT_SYMBOL(generic_make_request);
>  
>  /**
>   * submit_bio - submit a bio to the block device layer for I/O
> - * @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
>   * @bio: The &struct bio which describes the I/O
>   *
>   * submit_bio() is very similar in purpose to generic_make_request(), and
> @@ -2100,10 +2099,8 @@ EXPORT_SYMBOL(generic_make_request);
>   * interfaces; @bio must be presetup and ready for I/O.
>   *
>   */
> -blk_qc_t submit_bio(int rw, struct bio *bio)
> +blk_qc_t submit_bio(struct bio *bio)
>  {
> - bio->bi_rw |= rw;
> -
>   /*
>* If it's a regular read/write or a barrier with data attached,
>* go through the normal accounting stuff before submission.
> @@ -2111,12 +2108,12 @@ blk_qc_t submit_bio(int rw, struct bio *bio)
>   if (bio_has

Re: [Ocfs2-devel] [PATCH 34/35] block: add QUEUE_FLAGs for flush and fua

2016-01-09 Thread Christoph Hellwig
On Tue, Jan 05, 2016 at 02:53:37PM -0600, mchri...@redhat.com wrote:
> From: Mike Christie 
> 
> The last patch added a REQ_OP_FLUSH for request_fn drivers
> and the next patch renames REQ_FLUSH to REQ_PREFLUSH which
> will be used by file systems and make_request_fn drivers.
> 
> This leaves REQ_FLUSH/REQ_FUA defined for drivers to tell
> the block layer if flush/fua is supported. The names are
> confusing and I bet will will accidentally be used by
> people to request flushes. To avoid that, this patch adds
> QUEUE_FLAGs for flush and fua which drivers will use to
> indicate what they support.
> 
> Signed-off-by: Mike Christie 

Yes, this was rather confusing before.  Looks great fix the fix for th
kbuild complaint:

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 00/35 v2] separate operations from flags in the bio/request structs

2016-01-08 Thread Christoph Hellwig
This looks good to me from a highlevel point of view.
Do you also have a git tree to take a look at all the changes in a
single big diff?

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] simplify configfs attributes V2

2015-10-13 Thread Christoph Hellwig
On Mon, Oct 05, 2015 at 02:37:05PM -0700, Andrew Morton wrote:
> > This series consolidates the code to implement configfs attributes
> > by providing the ->show and ->store method in common code and using
> > container_of in the methods to access the containing structure.
> > 
> > This reduces source and binary size of configfs consumers a lot.
> 
> There's a version of this patch series (I assume V1) in linux-next via
> Nicholas's tree so my hands are tied.  I trust that Nicholas will
> update things.
> 
> Or maybe it was a slipup - modifying usb, ocfs2 etc from the iscsi tree
> is innovative ;)

Nic wanted this as the target code is the biggest user of configfs.
I don't really care where it goes as long as we get in the current version
into a stable not to be rebased branch somehwere so that all consumers
can use that as a base point.

Nic, can you do that?  A lot of previous work went in through Andrew, but I
think -mm is still a quilt stack so the stable base branch wouldn't be
possible that way.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 18/23] spear13xx_pcie_gadget: use per-attribute show and store methods

2015-10-11 Thread Christoph Hellwig
On Fri, Oct 09, 2015 at 04:05:17PM -0500, Felipe Balbi wrote:
> Pratyush Anand  writes:
> 
> > On Sat, Oct 3, 2015 at 7:02 PM, Christoph Hellwig  wrote:
> >> Signed-off-by: Christoph Hellwig 
> >
> > Acked-by: Pratyush Anand 
> 
> I don't seem to have the actual patch, care to resend?

The whole series was sent to all the receipients in the To and Cc lists,
so check your spam folder or one of the list archives.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-10-11 Thread Christoph Hellwig
On Fri, Oct 09, 2015 at 04:19:57PM -0500, Felipe Balbi wrote:
> > Signed-off-by: Christoph Hellwig 
> > Reviewed-by: Andrzej Pietrasiewicz 
> 
> I suppose this depends on other fs/configfs changes ?

The whole series should be applied in order, but doesn't have any
other dependencies.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] simplify configfs attributes V2

2015-10-11 Thread Christoph Hellwig
On Fri, Oct 09, 2015 at 04:37:51PM -0500, Felipe Balbi wrote:
> For reference, I'm fine if you guys take all patches through FS
> tree. Another option is waiting for dependencies to be merged in v4.4,
> and the gadget changes merge in v4.5, whatever works.

I'd prefer to take them all in one go.  If we really have to I could
drop the last patch for now and clean up later, but I'd prefer not to.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 03/23] usb-gadget/uvc: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
UVC is a little different from other configfs consumers in that it wants
different function and field names from the exposed attribute name, so
it keeps it's local macros to define attributes instead of using the common
ones.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/uvc_configfs.c | 387 +++--
 1 file changed, 143 insertions(+), 244 deletions(-)

diff --git a/drivers/usb/gadget/function/uvc_configfs.c 
b/drivers/usb/gadget/function/uvc_configfs.c
index 3c0467b..289ebca 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -17,19 +17,21 @@
 
 #define UVCG_STREAMING_CONTROL_SIZE1
 
-#define CONFIGFS_ATTR_OPS_RO(_item)\
-static ssize_t _item##_attr_show(struct config_item *item, \
-struct configfs_attribute *attr,   \
-char *page)\
-{  \
-   struct _item *_item = to_##_item(item); \
-   struct _item##_attribute *_item##_attr =\
-   container_of(attr, struct _item##_attribute, attr); \
-   ssize_t ret = 0;\
-   \
-   if (_item##_attr->show) \
-   ret = _item##_attr->show(_item, page);  \
-   return ret; \
+#define UVC_ATTR(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
+   .store  = prefix##cname##_store,\
+}
+
+#define UVC_ATTR_RO(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
 }
 
 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item);
@@ -48,18 +50,11 @@ static struct uvcg_control_header 
*to_uvcg_control_header(struct config_item *it
return container_of(item, struct uvcg_control_header, item);
 }
 
-CONFIGFS_ATTR_STRUCT(uvcg_control_header);
-CONFIGFS_ATTR_OPS(uvcg_control_header);
-
-static struct configfs_item_operations uvcg_control_header_item_ops = {
-   .show_attribute = uvcg_control_header_attr_show,
-   .store_attribute= uvcg_control_header_attr_store,
-};
-
 #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit)
\
 static ssize_t uvcg_control_header_##cname##_show( \
-   struct uvcg_control_header *ch, char *page) \
+   struct config_item *item, char *page)   \
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@@ -79,9 +74,10 @@ static ssize_t uvcg_control_header_##cname##_show(   
\
 }  \
\
 static ssize_t \
-uvcg_control_header_##cname##_store(struct uvcg_control_header *ch,\
+uvcg_control_header_##cname##_store(struct config_item *item,  \
   const char *page, size_t len)\
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@@ -115,11 +111,7 @@ end:   

[Ocfs2-devel] [PATCH 23/23] configfs: remove old API

2015-10-03 Thread Christoph Hellwig
Remove the old show_attribute and store_attribute methods and update
the documentation.  Also replace the two C samples with a single new
one in the proper samples directory where people expect to find it.

Signed-off-by: Christoph Hellwig 
---
 Documentation/filesystems/Makefile |   2 -
 Documentation/filesystems/configfs/Makefile|   3 -
 Documentation/filesystems/configfs/configfs.txt|  38 +-
 .../configfs/configfs_example_explicit.c   | 483 -
 .../filesystems/configfs/configfs_example_macros.c | 446 ---
 fs/configfs/file.c |  15 +-
 include/linux/configfs.h   |  82 
 samples/Kconfig|   6 +
 samples/Makefile   |   3 +-
 samples/configfs/Makefile  |   2 +
 samples/configfs/configfs_sample.c | 404 +
 11 files changed, 428 insertions(+), 1056 deletions(-)
 delete mode 100644 Documentation/filesystems/configfs/Makefile
 delete mode 100644 
Documentation/filesystems/configfs/configfs_example_explicit.c
 delete mode 100644 Documentation/filesystems/configfs/configfs_example_macros.c
 create mode 100644 samples/configfs/Makefile
 create mode 100644 samples/configfs/configfs_sample.c

diff --git a/Documentation/filesystems/Makefile 
b/Documentation/filesystems/Makefile
index 13483d1..883010c 100644
--- a/Documentation/filesystems/Makefile
+++ b/Documentation/filesystems/Makefile
@@ -1,5 +1,3 @@
-subdir-y := configfs
-
 # List of programs to build
 hostprogs-y := dnotify_test
 
diff --git a/Documentation/filesystems/configfs/Makefile 
b/Documentation/filesystems/configfs/Makefile
deleted file mode 100644
index be7ec5e..000
--- a/Documentation/filesystems/configfs/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-ifneq ($(CONFIG_CONFIGFS_FS),)
-obj-m += configfs_example_explicit.o configfs_example_macros.o
-endif
diff --git a/Documentation/filesystems/configfs/configfs.txt 
b/Documentation/filesystems/configfs/configfs.txt
index b40fec9..af68efd 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -160,12 +160,6 @@ among other things.  For that, it needs a type.
 
struct configfs_item_operations {
void (*release)(struct config_item *);
-   ssize_t (*show_attribute)(struct config_item *,
- struct configfs_attribute *,
- char *);
-   ssize_t (*store_attribute)(struct config_item *,
-  struct configfs_attribute *,
-  const char *, size_t);
int (*allow_link)(struct config_item *src,
  struct config_item *target);
int (*drop_link)(struct config_item *src,
@@ -183,9 +177,7 @@ The most basic function of a config_item_type is to define 
what
 operations can be performed on a config_item.  All items that have been
 allocated dynamically will need to provide the ct_item_ops->release()
 method.  This method is called when the config_item's reference count
-reaches zero.  Items that wish to display an attribute need to provide
-the ct_item_ops->show_attribute() method.  Similarly, storing a new
-attribute value uses the store_attribute() method.
+reaches zero.
 
 [struct configfs_attribute]
 
@@ -193,6 +185,8 @@ attribute value uses the store_attribute() method.
char*ca_name;
struct module   *ca_owner;
umode_t  ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
};
 
 When a config_item wants an attribute to appear as a file in the item's
@@ -202,10 +196,10 @@ config_item_type->ct_attrs.  When the item appears in 
configfs, the
 attribute file will appear with the configfs_attribute->ca_name
 filename.  configfs_attribute->ca_mode specifies the file permissions.
 
-If an attribute is readable and the config_item provides a
-ct_item_ops->show_attribute() method, that method will be called
-whenever userspace asks for a read(2) on the attribute.  The converse
-will happen for write(2).
+If an attribute is readable and provides a ->show method, that method will
+be called whenever userspace asks for a read(2) on the attribute.  If an
+attribute is writable and provides a ->store  method, that method will be
+be called whenever userspace asks for a write(2) on the attribute.
 
 [struct config_group]
 
@@ -311,20 +305,10 @@ the subsystem must be ready for it.
 [An Example]
 
 The best example of these basic concepts is the simple_children
-subsystem/group and the simple_child item in configfs_example_explicit.c
-and conf

[Ocfs2-devel] [PATCH 21/23] ocfs2/cluster: move locking into attribute store methods

2015-10-03 Thread Christoph Hellwig
The test and separate set bit scheme was racy to start with, so move to do
a test_and_set_bit after doing the earlier error checks inside the actual
store methods.  Also remove the locking for the local attribute which
already has a different scheme to synchronize.

Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/nodemanager.c | 54 +++---
 1 file changed, 19 insertions(+), 35 deletions(-)

diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 441c84e..7a398f6 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -188,7 +188,6 @@ enum {
O2NM_NODE_ATTR_NUM = 0,
O2NM_NODE_ATTR_PORT,
O2NM_NODE_ATTR_ADDRESS,
-   O2NM_NODE_ATTR_LOCAL,
 };
 
 static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page,
@@ -197,6 +196,7 @@ static ssize_t o2nm_node_num_write(struct o2nm_node *node, 
const char *page,
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
unsigned long tmp;
char *p = (char *)page;
+   int ret = 0;
 
tmp = simple_strtoul(p, &p, 0);
if (!p || (*p && (*p != '\n')))
@@ -215,15 +215,18 @@ static ssize_t o2nm_node_num_write(struct o2nm_node 
*node, const char *page,
 
write_lock(&cluster->cl_nodes_lock);
if (cluster->cl_nodes[tmp])
-   p = NULL;
+   ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_NUM,
+   &node->nd_set_attributes))
+   ret = -EBUSY;
else  {
cluster->cl_nodes[tmp] = node;
node->nd_num = tmp;
set_bit(tmp, cluster->cl_nodes_bitmap);
}
write_unlock(&cluster->cl_nodes_lock);
-   if (p == NULL)
-   return -EEXIST;
+   if (ret)
+   return ret;
 
return count;
 }
@@ -247,6 +250,8 @@ static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node 
*node,
if (tmp >= (u16)-1)
return -ERANGE;
 
+   if (test_and_set_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))
+   return -EBUSY;
node->nd_ipv4_port = htons(tmp);
 
return count;
@@ -282,6 +287,9 @@ static ssize_t o2nm_node_ipv4_address_write(struct 
o2nm_node *node,
write_lock(&cluster->cl_nodes_lock);
if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent))
ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS,
+   &node->nd_set_attributes))
+   ret = -EBUSY;
else {
rb_link_node(&node->nd_ip_node, parent, p);
rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree);
@@ -388,24 +396,13 @@ static struct o2nm_node_attribute o2nm_node_attr_local = {
 };
 
 static struct configfs_attribute *o2nm_node_attrs[] = {
-   [O2NM_NODE_ATTR_NUM] = &o2nm_node_attr_num.attr,
-   [O2NM_NODE_ATTR_PORT] = &o2nm_node_attr_ipv4_port.attr,
-   [O2NM_NODE_ATTR_ADDRESS] = &o2nm_node_attr_ipv4_address.attr,
-   [O2NM_NODE_ATTR_LOCAL] = &o2nm_node_attr_local.attr,
+   &o2nm_node_attr_num.attr,
+   &o2nm_node_attr_ipv4_port.attr,
+   &o2nm_node_attr_ipv4_address.attr,
+   &o2nm_node_attr_local.attr,
NULL,
 };
 
-static int o2nm_attr_index(struct configfs_attribute *attr)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) {
-   if (attr == o2nm_node_attrs[i])
-   return i;
-   }
-   BUG();
-   return 0;
-}
-
 static ssize_t o2nm_node_show(struct config_item *item,
  struct configfs_attribute *attr,
  char *page)
@@ -427,24 +424,11 @@ static ssize_t o2nm_node_store(struct config_item *item,
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_node_attribute *o2nm_node_attr =
container_of(attr, struct o2nm_node_attribute, attr);
-   ssize_t ret;
-   int attr_index = o2nm_attr_index(attr);
 
-   if (o2nm_node_attr->store == NULL) {
-   ret = -EINVAL;
-   goto out;
-   }
-
-   if (test_bit(attr_index, &node->nd_set_attributes))
-   return -EBUSY;
-
-   ret = o2nm_node_attr->store(node, page, count);
-   if (ret < count)
-   goto out;
+   if (o2nm_node_attr->store == NULL)
+   return -EINVAL;
 
-   set_bit(attr_index, &node->nd_set_attributes);
-out:
-   return ret;
+   return o2nm_node_attr->store(node, page, count);
 }
 
 static struct configfs_item_operations o2nm_node_item_ops = {
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 08/23] usb-gadget/f_midi: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_midi.c | 37 
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index a287a48..0e2b8ed 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -906,9 +906,6 @@ static inline struct f_midi_opts *to_f_midi_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_midi_opts);
-CONFIGFS_ATTR_OPS(f_midi_opts);
-
 static void midi_attr_release(struct config_item *item)
 {
struct f_midi_opts *opts = to_f_midi_opts(item);
@@ -918,13 +915,12 @@ static void midi_attr_release(struct config_item *item)
 
 static struct configfs_item_operations midi_item_ops = {
.release= midi_attr_release,
-   .show_attribute = f_midi_opts_attr_show,
-   .store_attribute = f_midi_opts_attr_store,
 };
 
 #define F_MIDI_OPT(name, test_limit, limit)\
-static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) 
\
+static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) 
\
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -934,9 +930,10 @@ static ssize_t f_midi_opts_##name##_show(struct 
f_midi_opts *opts, char *page) \
return result;  \
 }  \
\
-static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts,\
+static ssize_t f_midi_opts_##name##_store(struct config_item *item,\
 const char *page, size_t len)  \
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int ret;\
u32 num;\
\
@@ -962,9 +959,7 @@ end:
\
return ret; \
 }  \
\
-static struct f_midi_opts_attribute f_midi_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \
-   f_midi_opts_##name##_store)
+CONFIGFS_ATTR(f_midi_opts_, name);
 
 F_MIDI_OPT(index, true, SNDRV_CARDS);
 F_MIDI_OPT(buflen, false, 0);
@@ -972,8 +967,9 @@ F_MIDI_OPT(qlen, false, 0);
 F_MIDI_OPT(in_ports, true, MAX_PORTS);
 F_MIDI_OPT(out_ports, true, MAX_PORTS);
 
-static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
+static ssize_t f_midi_opts_id_show(struct config_item *item, char *page)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -989,9 +985,10 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts,
+static ssize_t f_midi_opts_id_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int ret;
char *c;
 
@@ -1016,17 +1013,15 @@ end:
return ret;
 }
 
-static struct f_midi_opts_attribute f_midi_opts_id =
-   __CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show,
-   f_midi_opts_id_store);
+CONFIGFS_ATTR(f_midi_opts_, id);
 
 static struct configfs_attribute *midi_attrs[] = {
-   &f_midi_opts_index.attr,
-   &f_midi_opts_buflen.attr,
-   &f_midi_opts_qlen.attr,
-   &f_midi_opts_in_ports.attr,
-   &f_midi_opts_out_ports.attr,
-   &f_midi_opts_id.attr,
+   &f_midi_opts_attr_index,
+   &f_midi_opts_attr_buflen,
+   &f_midi_opts_attr_qlen,
+   &f_midi_opts_attr_in_ports,
+   &f_midi_opts_attr_out_ports,
+   &f_midi_opts_attr_id,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 04/23] usb-gadget/f_hid: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_hid.c | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 6df9715..d15b061 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -713,9 +713,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_hid_opts);
-CONFIGFS_ATTR_OPS(f_hid_opts);
-
 static void hid_attr_release(struct config_item *item)
 {
struct f_hid_opts *opts = to_f_hid_opts(item);
@@ -725,13 +722,12 @@ static void hid_attr_release(struct config_item *item)
 
 static struct configfs_item_operations hidg_item_ops = {
.release= hid_attr_release,
-   .show_attribute = f_hid_opts_attr_show,
-   .store_attribute = f_hid_opts_attr_store,
 };
 
 #define F_HID_OPT(name, prec, limit)   \
-static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
+static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int result; \
\
mutex_lock(&opts->lock);\
@@ -741,9 +737,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts 
*opts, char *page)\
return result;  \
 }  \
\
-static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts,  \
+static ssize_t f_hid_opts_##name##_store(struct config_item *item, \
 const char *page, size_t len)  \
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int ret;\
u##prec num;\
\
@@ -769,16 +766,15 @@ end:  
\
return ret; \
 }  \
\
-static struct f_hid_opts_attribute f_hid_opts_##name = \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
-   f_hid_opts_##name##_store)
+CONFIGFS_ATTR(f_hid_opts_, name)
 
 F_HID_OPT(subclass, 8, 255);
 F_HID_OPT(protocol, 8, 255);
 F_HID_OPT(report_length, 16, 65535);
 
-static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
+static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char 
*page)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -789,9 +785,10 @@ static ssize_t f_hid_opts_report_desc_show(struct 
f_hid_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
+static ssize_t f_hid_opts_report_desc_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int ret = -EBUSY;
char *d;
 
@@ -818,16 +815,13 @@ end:
return ret;
 }
 
-static struct f_hid_opts_attribute f_hid_opts_report_desc =
-   __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
-   f_hid_opts_report_desc_show,
-   f_hid_opts_report_desc_store);
+CONFIGFS_ATTR(f_hid_opts_, report_desc);
 
 static struct configfs_attribute *hid_attrs[] = {
-   &f_hid_opts_subclass.attr,
-   &f_hid_opts_protocol.attr,
-   &f_hid_opts_report_length.attr,
-   &f_hid_opts_report_desc.attr,
+   &f_hid_opts_attr_subclass,
+   &f_hid_opts_attr_protocol,
+   &f_hid_opts_attr_report_length,
+   &f_hid_opts_attr_report_desc,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 22/23] ocfs2/cluster: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/heartbeat.c   | 205 +++
 fs/ocfs2/cluster/nodemanager.c | 241 ++---
 2 files changed, 100 insertions(+), 346 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index fa15deb..e404386 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1473,16 +1473,17 @@ static int o2hb_read_block_input(struct o2hb_region 
*reg,
return 0;
 }
 
-static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%u\n", reg->hr_block_bytes);
+   return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes);
 }
 
-static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
int status;
unsigned long block_bytes;
unsigned int block_bits;
@@ -1501,16 +1502,17 @@ static ssize_t o2hb_region_block_bytes_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%llu\n", reg->hr_start_block);
+   return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block);
 }
 
-static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
 
@@ -1526,16 +1528,16 @@ static ssize_t o2hb_region_start_block_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%d\n", reg->hr_blocks);
+   return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks);
 }
 
-static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_blocks_store(struct config_item *item,
const char *page,
size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long tmp;
char *p = (char *)page;
 
@@ -1554,13 +1556,12 @@ static ssize_t o2hb_region_blocks_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_dev_read(struct o2hb_region *reg,
-   char *page)
+static ssize_t o2hb_region_dev_show(struct config_item *item, char *page)
 {
unsigned int ret = 0;
 
-   if (reg->hr_bdev)
-   ret = sprintf(page, "%s\n", reg->hr_dev_name);
+   if (to_o2hb_region(item)->hr_bdev)
+   ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name);
 
return ret;
 }
@@ -1670,10 +1671,11 @@ out:
 }
 
 /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
-static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_dev_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
struct task_struct *hb_task;
long fd;
int sectsize;
@@ -1828,9 +1830,9 @@ out:
return ret;
 }
 
-static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_pid_show(struct config_item *item, char *page)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
pid_t pid = 0;
 
spin_lock(&o2hb_live_lock);
@@ -1844,92 +1846,23 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region 
*reg,
return sprintf(page, "%u\n", pid);
 }
 
-struct o2hb_region_attribute {
-   struct configfs_attribute attr;
-   ssize_t (*show)(struct o2hb_region *, char *);
-   ssize_t (*store)(struct o2hb_region *, const char *, size_t);
-};
-
-static struct o2hb_region_attribute o2hb_region_attr_block_bytes = {
-   .attr   = { .ca_owner = THIS_MODULE,
-   .ca_name = "

[Ocfs2-devel] [PATCH 07/23] usb-gadget/f_loopback: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_loopback.c | 31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index 6e2fe63..b9d8f05 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -413,9 +413,6 @@ static inline struct f_lb_opts *to_f_lb_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_lb_opts);
-CONFIGFS_ATTR_OPS(f_lb_opts);
-
 static void lb_attr_release(struct config_item *item)
 {
struct f_lb_opts *lb_opts = to_f_lb_opts(item);
@@ -425,12 +422,11 @@ static void lb_attr_release(struct config_item *item)
 
 static struct configfs_item_operations lb_item_ops = {
.release= lb_attr_release,
-   .show_attribute = f_lb_opts_attr_show,
-   .store_attribute= f_lb_opts_attr_store,
 };
 
-static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -440,9 +436,10 @@ static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, 
char *page)
return result;
 }
 
-static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_qlen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -463,13 +460,11 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_qlen =
-   __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR,
-   f_lb_opts_qlen_show,
-   f_lb_opts_qlen_store);
+CONFIGFS_ATTR(f_lb_opts_, qlen);
 
-static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -479,9 +474,10 @@ static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -502,14 +498,11 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_bulk_buflen =
-   __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR,
-   f_lb_opts_bulk_buflen_show,
-   f_lb_opts_bulk_buflen_store);
+CONFIGFS_ATTR(f_lb_opts_, bulk_buflen);
 
 static struct configfs_attribute *lb_attrs[] = {
-   &f_lb_opts_qlen.attr,
-   &f_lb_opts_bulk_buflen.attr,
+   &f_lb_opts_attr_qlen,
+   &f_lb_opts_attr_bulk_buflen,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 18/23] spear13xx_pcie_gadget: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/misc/spear13xx_pcie_gadget.c | 216 ---
 1 file changed, 71 insertions(+), 145 deletions(-)

diff --git a/drivers/misc/spear13xx_pcie_gadget.c 
b/drivers/misc/spear13xx_pcie_gadget.c
index b8374cd..ee120dc 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -220,11 +220,17 @@ static irqreturn_t spear_pcie_gadget_irq(int irq, void 
*dev_id)
 /*
  * configfs interfaces show/store functions
  */
-static ssize_t pcie_gadget_show_link(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+
+static struct pcie_gadget_target *to_target(struct config_item *item)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   return item ?
+   container_of(to_configfs_subsystem(to_config_group(item)),
+   struct pcie_gadget_target, subsys) : NULL;
+}
+
+static ssize_t pcie_gadget_link_show(struct config_item *item, char *buf)
+{
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID))
return sprintf(buf, "UP");
@@ -232,11 +238,10 @@ static ssize_t pcie_gadget_show_link(
return sprintf(buf, "DOWN");
 }
 
-static ssize_t pcie_gadget_store_link(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_link_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (sysfs_streq(buf, "UP"))
writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID),
@@ -250,17 +255,15 @@ static ssize_t pcie_gadget_store_link(
return count;
 }
 
-static ssize_t pcie_gadget_show_int_type(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf)
 {
-   return sprintf(buf, "%s", config->int_type);
+   return sprintf(buf, "%s", to_target(item)->int_type);
 }
 
-static ssize_t pcie_gadget_store_int_type(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_int_type_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
u32 cap, vec, flags;
ulong vector;
 
@@ -288,11 +291,10 @@ static ssize_t pcie_gadget_store_int_type(
return count;
 }
 
-static ssize_t pcie_gadget_show_no_of_msi(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct spear_pcie_gadget_config *config = to_target(item)
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
u32 cap, vec, flags;
ulong vector;
 
@@ -313,13 +315,12 @@ static ssize_t pcie_gadget_show_no_of_msi(
return sprintf(buf, "%lu", vector);
 }
 
-static ssize_t pcie_gadget_store_no_of_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
int ret;
 
-   ret = kstrtoul(buf, 0, &config->requested_msi);
+   ret = kstrtoul(buf, 0, &to_target(item)->requested_msi);
if (ret)
return ret;
 
@@ -329,11 +330,10 @@ static ssize_t pcie_gadget_store_no_of_msi(
return count;
 }
 
-static ssize_t pcie_gadget_store_inta(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_inta_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
ulong en;
int ret;
 
@@ -351,10 +351,10 @@ static ssize_t pcie_gadget_store_inta(
return count;
 }
 
-static ssize_t pcie_gadget_store_send_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_send_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
ulong vector;
u32 ven_msi;
@@ -388,19 +388,16 @@ static ssize_t pcie_gadget_store_send_msi(
return count;
 }
 
-static ssize_t pcie_gadget_show_vendor_id(
-   struct spear_pcie_gadget_config *config,
-   char *bu

[Ocfs2-devel] [PATCH 06/23] usb-gadget/ether: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_ecm.c|  8 ++---
 drivers/usb/gadget/function/f_eem.c|  8 ++---
 drivers/usb/gadget/function/f_ncm.c|  8 ++---
 drivers/usb/gadget/function/f_rndis.c  |  8 ++---
 drivers/usb/gadget/function/f_subset.c |  8 ++---
 drivers/usb/gadget/function/u_ether_configfs.h | 44 +++---
 6 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 7b7424f..0106de8 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -855,10 +855,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
 
 static struct configfs_attribute *ecm_attrs[] = {
-   &f_ecm_opts_dev_addr.attr,
-   &f_ecm_opts_host_addr.attr,
-   &f_ecm_opts_qmult.attr,
-   &f_ecm_opts_ifname.attr,
+   &ecm_opts_attr_dev_addr,
+   &ecm_opts_attr_host_addr,
+   &ecm_opts_attr_qmult,
+   &ecm_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index c9e90de..f965403 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -555,10 +555,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
 
 static struct configfs_attribute *eem_attrs[] = {
-   &f_eem_opts_dev_addr.attr,
-   &f_eem_opts_host_addr.attr,
-   &f_eem_opts_qmult.attr,
-   &f_eem_opts_ifname.attr,
+   &eem_opts_attr_dev_addr,
+   &eem_opts_attr_host_addr,
+   &eem_opts_attr_qmult,
+   &eem_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_ncm.c 
b/drivers/usb/gadget/function/f_ncm.c
index 3f05c6bd..01a99e5 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1503,10 +1503,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
 
 static struct configfs_attribute *ncm_attrs[] = {
-   &f_ncm_opts_dev_addr.attr,
-   &f_ncm_opts_host_addr.attr,
-   &f_ncm_opts_qmult.attr,
-   &f_ncm_opts_ifname.attr,
+   &ncm_opts_attr_dev_addr,
+   &ncm_opts_attr_host_addr,
+   &ncm_opts_attr_qmult,
+   &ncm_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_rndis.c 
b/drivers/usb/gadget/function/f_rndis.c
index 32985da..a04b526 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -878,10 +878,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
 
 static struct configfs_attribute *rndis_attrs[] = {
-   &f_rndis_opts_dev_addr.attr,
-   &f_rndis_opts_host_addr.attr,
-   &f_rndis_opts_qmult.attr,
-   &f_rndis_opts_ifname.attr,
+   &rndis_opts_attr_dev_addr,
+   &rndis_opts_attr_host_addr,
+   &rndis_opts_attr_qmult,
+   &rndis_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_subset.c 
b/drivers/usb/gadget/function/f_subset.c
index e3dfa67..055e4ea 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -413,10 +413,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
 
 static struct configfs_attribute *gether_attrs[] = {
-   &f_gether_opts_dev_addr.attr,
-   &f_gether_opts_host_addr.attr,
-   &f_gether_opts_qmult.attr,
-   &f_gether_opts_ifname.attr,
+   &gether_opts_attr_dev_addr,
+   &gether_opts_attr_host_addr,
+   &gether_opts_attr_qmult,
+   &gether_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h 
b/drivers/usb/gadget/function/u_ether_configfs.h
index bcbd301..4f47289 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -17,9 +17,6 @@
 #define __U_ETHER_CONFIGFS_H
 
 #define USB_ETHERNET_CONFIGFS_ITEM(_f_)
\
-   CONFIGFS_ATTR_STRUCT(f_##_f_##_opts);   \
-   CONFIGFS_ATTR_OPS(f_##_f_##_opts);  \
-   \
static void _f_##_attr_release(struct config_item *item)\
{   \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item);  \
@@ -29,14 +26,13 @@

[Ocfs2-devel] [PATCH 17/23] dlm: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: David Teigland cl_cluster_name);
 }
 
-static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl,
+static ssize_t cluster_cluster_name_store(struct config_item *item,
  const char *buf, size_t len)
 {
+   struct dlm_cluster *cl = config_item_to_cluster(item);
+
strlcpy(dlm_config.ci_cluster_name, buf,
sizeof(dlm_config.ci_cluster_name));
strlcpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name));
return len;
 }
 
-static struct cluster_attribute cluster_attr_cluster_name = {
-   .attr   = { .ca_owner = THIS_MODULE,
-.ca_name = "cluster_name",
-.ca_mode = S_IRUGO | S_IWUSR },
-   .show   = cluster_cluster_name_read,
-   .store  = cluster_cluster_name_write,
-};
+CONFIGFS_ATTR(cluster_, cluster_name);
 
 static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
   int *info_field, int check_zero,
@@ -175,17 +145,19 @@ static ssize_t cluster_set(struct dlm_cluster *cl, 
unsigned int *cl_field,
 }
 
 #define CLUSTER_ATTR(name, check_zero)\
-static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t 
len) \
+static ssize_t cluster_##name##_store(struct config_item *item, \
+   const char *buf, size_t len) \
 { \
+   struct dlm_cluster *cl = config_item_to_cluster(item);\
return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name, \
   check_zero, buf, len); \
 } \
-static ssize_t name##_read(struct dlm_cluster *cl, char *buf) \
+static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
 { \
+   struct dlm_cluster *cl = config_item_to_cluster(item);\
return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name);   \
 } \
-static struct cluster_attribute cluster_attr_##name = \
-__CONFIGFS_ATTR(name, 0644, name##_read, name##_write)
+CONFIGFS_ATTR(cluster_, name);
 
 CLUSTER_ATTR(tcp_port, 1);
 CLUSTER_ATTR(buffer_size, 1);
@@ -201,19 +173,19 @@ CLUSTER_ATTR(new_rsb_count, 0);
 CLUSTER_ATTR(recover_callbacks, 0);
 
 static struct configfs_attribute *cluster_attrs[] = {
-   [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr,
-   [CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size.attr,
-   [CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size.attr,
-   [CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer.attr,
-   [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr,
-   [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr,
-   [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr,
-   [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol.attr,
-   [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr,
-   [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us.attr,
-   [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count.attr,
-   [CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks.attr,
-   [CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name.attr,
+   [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port,
+   [CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size,
+   [CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size,
+   [CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer,
+   [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs,
+   [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs,
+   [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug,
+   [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol,
+   [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs,
+   [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us,
+   [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count,
+   [CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks,
+   [CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name,
NULL,
 };
 
@@ -224,83 +196,11 @@ enum {
COMM_ATTR_ADDR_LIST,
 };
 
-struct comm_attribute {
-   struct configfs_attribute attr;
-   ssize_t (*show)(struct dlm_comm *, char *);
-   ssize_t (*store)(struct dlm_comm *, const char *, size_t);
-};
-
-static struct comm_attribute comm_attr_nod

[Ocfs2-devel] [PATCH 13/23] usb-gadget/f_uac2: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uac2.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c 
b/drivers/usb/gadget/function/f_uac2.c
index f8de7ea..0a5a1e1 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1445,9 +1445,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac2_opts);
-CONFIGFS_ATTR_OPS(f_uac2_opts);
-
 static void f_uac2_attr_release(struct config_item *item)
 {
struct f_uac2_opts *opts = to_f_uac2_opts(item);
@@ -1457,14 +1454,13 @@ static void f_uac2_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations f_uac2_item_ops = {
.release= f_uac2_attr_release,
-   .show_attribute = f_uac2_opts_attr_show,
-   .store_attribute = f_uac2_opts_attr_store,
 };
 
 #define UAC2_ATTRIBUTE(name)   \
-static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \
+static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -1474,9 +1470,10 @@ static ssize_t f_uac2_opts_##name##_show(struct 
f_uac2_opts *opts,   \
return result;  \
 }  \
\
-static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts,\
+static ssize_t f_uac2_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int ret;\
u32 num;\
\
@@ -1498,10 +1495,7 @@ end: 
\
return ret; \
 }  \
\
-static struct f_uac2_opts_attribute f_uac2_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac2_opts_##name##_show,  \
-   f_uac2_opts_##name##_store)
+CONFIGFS_ATTR(f_uac2_opts_, name)
 
 UAC2_ATTRIBUTE(p_chmask);
 UAC2_ATTRIBUTE(p_srate);
@@ -1511,12 +1505,12 @@ UAC2_ATTRIBUTE(c_srate);
 UAC2_ATTRIBUTE(c_ssize);
 
 static struct configfs_attribute *f_uac2_attrs[] = {
-   &f_uac2_opts_p_chmask.attr,
-   &f_uac2_opts_p_srate.attr,
-   &f_uac2_opts_p_ssize.attr,
-   &f_uac2_opts_c_chmask.attr,
-   &f_uac2_opts_c_srate.attr,
-   &f_uac2_opts_c_ssize.attr,
+   &f_uac2_opts_attr_p_chmask,
+   &f_uac2_opts_attr_p_srate,
+   &f_uac2_opts_attr_p_ssize,
+   &f_uac2_opts_attr_c_chmask,
+   &f_uac2_opts_attr_c_srate,
+   &f_uac2_opts_attr_c_ssize,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 12/23] usb-gadget/f_uac1: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_uac1.c | 39 +++-
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac1.c 
b/drivers/usb/gadget/function/f_uac1.c
index 7856b33..ad01032 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -773,9 +773,6 @@ static inline struct f_uac1_opts *to_f_uac1_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac1_opts);
-CONFIGFS_ATTR_OPS(f_uac1_opts);
-
 static void f_uac1_attr_release(struct config_item *item)
 {
struct f_uac1_opts *opts = to_f_uac1_opts(item);
@@ -785,14 +782,13 @@ static void f_uac1_attr_release(struct config_item *item)
 
 static struct configfs_item_operations f_uac1_item_ops = {
.release= f_uac1_attr_release,
-   .show_attribute = f_uac1_opts_attr_show,
-   .store_attribute = f_uac1_opts_attr_store,
 };
 
 #define UAC1_INT_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -802,9 +798,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,
\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret;\
u32 num;\
\
@@ -826,19 +823,17 @@ end:  
\
return ret; \
 }  \
\
-static struct f_uac1_opts_attribute f_uac1_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac1_opts_##name##_show,  \
-   f_uac1_opts_##name##_store)
+CONFIGFS_ATTR(f_uac1_opts_, name)
 
 UAC1_INT_ATTRIBUTE(req_buf_size);
 UAC1_INT_ATTRIBUTE(req_count);
 UAC1_INT_ATTRIBUTE(audio_buf_size);
 
 #define UAC1_STR_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -848,9 +843,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret = -EBUSY;   \
   

[Ocfs2-devel] [PATCH 10/23] usb-gadget/f_sourcesink: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_sourcesink.c | 83 +-
 1 file changed, 36 insertions(+), 47 deletions(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c 
b/drivers/usb/gadget/function/f_sourcesink.c
index cbfaf86..878a581 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -898,9 +898,6 @@ static inline struct f_ss_opts *to_f_ss_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_ss_opts);
-CONFIGFS_ATTR_OPS(f_ss_opts);
-
 static void ss_attr_release(struct config_item *item)
 {
struct f_ss_opts *ss_opts = to_f_ss_opts(item);
@@ -910,12 +907,11 @@ static void ss_attr_release(struct config_item *item)
 
 static struct configfs_item_operations ss_item_ops = {
.release= ss_attr_release,
-   .show_attribute = f_ss_opts_attr_show,
-   .store_attribute= f_ss_opts_attr_store,
 };
 
-static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -925,9 +921,10 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_pattern_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -953,13 +950,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_pattern =
-   __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR,
-   f_ss_opts_pattern_show,
-   f_ss_opts_pattern_store);
+CONFIGFS_ATTR(f_ss_opts_, pattern);
 
-static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -969,9 +964,10 @@ static ssize_t f_ss_opts_isoc_interval_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -997,13 +993,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_interval =
-   __CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_interval_show,
-   f_ss_opts_isoc_interval_store);
+CONFIGFS_ATTR(f_ss_opts_, isoc_interval);
 
-static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char 
*page)
+static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1013,9 +1007,10 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u16 num;
 
@@ -1041,13 +1036,11 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket =
-   __CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_maxpacket_show,
-   f_ss_opts_isoc_maxpacket_store);
+CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket);
 
-static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1057,9 +1050,10 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -1085,13 +1079,11 @@ end:
return ret;
 }
 
-stati

[Ocfs2-devel] [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/configfs.c   | 295 ++--
 include/linux/usb/gadget_configfs.h |  19 +--
 2 files changed, 118 insertions(+), 196 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 294eb74..163d305 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -64,6 +64,11 @@ struct gadget_info {
char qw_sign[OS_STRING_QW_SIGN_LEN];
 };
 
+static inline struct gadget_info *to_gadget_info(struct config_item *item)
+{
+return container_of(to_config_group(item), struct gadget_info, group);
+}
+
 struct config_usb_cfg {
struct config_group group;
struct config_group strings_group;
@@ -74,6 +79,12 @@ struct config_usb_cfg {
struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
 };
 
+static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item 
*item)
+{
+   return container_of(to_config_group(item), struct config_usb_cfg,
+   group);
+}
+
 struct gadget_strings {
struct usb_gadget_strings stringtab_dev;
struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
@@ -117,32 +128,25 @@ static int usb_string_copy(const char *s, char **s_copy)
return 0;
 }
 
-CONFIGFS_ATTR_STRUCT(gadget_info);
-CONFIGFS_ATTR_STRUCT(config_usb_cfg);
-
-#define GI_DEVICE_DESC_ITEM_ATTR(name) \
-   static struct gadget_info_attribute gadget_cdev_desc_##name = \
-   __CONFIGFS_ATTR(name,  S_IRUGO | S_IWUSR,   \
-   gadget_dev_desc_##name##_show,  \
-   gadget_dev_desc_##name##_store)
-
 #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \
+   return sprintf(page, "0x%02x\n", \
+   to_gadget_info(item)->cdev.desc.__name); \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_R_u16(__name)\
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%04x\n", le16_to_cpup(&gi->cdev.desc.__name)); \
+   return sprintf(page, "0x%04x\n", \
+   le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \
 }
 
 
 #define GI_DEVICE_DESC_SIMPLE_W_u8(_name)  \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u8 val; \
@@ -150,12 +154,12 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou8(page, 0, &val);  \
if (ret)\
return ret; \
-   gi->cdev.desc._name = val;  \
+   to_gadget_info(item)->cdev.desc._name = val;\
return len; \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u16 val;\
@@ -163,7 +167,7 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou16(page, 0, &val); \
if (ret)\
return ret; \
-   gi->cdev.desc._name = cpu_to_le16p(&val);   \
+   to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \
return len; \
 }
 
@@ -193,7 +197,7 @@ static ssize_t is_valid_bcd(u16 bcd_val)
return 0;
 }
 
-static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi,
+static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
const char *page, size_t len)
 {
u16 bcdDevice;
@@ -206,11 +210,11 @@ static ssize_t gadget_dev_desc_bcdDevice_store(struct 
gadget_info *gi,
if (ret)
return ret;
 
-   gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
+   to_gadget_info(it

[Ocfs2-devel] [PATCH 11/23] usb-gadget/f_mass_storage: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_mass_storage.c | 119 +++
 1 file changed, 46 insertions(+), 73 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index a6eb537..1ab089f 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3144,9 +3144,6 @@ static inline struct fsg_opts *to_fsg_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(fsg_lun_opts);
-CONFIGFS_ATTR_OPS(fsg_lun_opts);
-
 static void fsg_lun_attr_release(struct config_item *item)
 {
struct fsg_lun_opts *lun_opts;
@@ -3157,110 +3154,93 @@ static void fsg_lun_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations fsg_lun_item_ops = {
.release= fsg_lun_attr_release,
-   .show_attribute = fsg_lun_opts_attr_show,
-   .store_attribute= fsg_lun_opts_attr_store,
 };
 
-static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page);
 }
 
-static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_file_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_file =
-   __CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show,
-   fsg_lun_opts_file_store);
+CONFIGFS_ATTR(fsg_lun_opts_, file);
 
-static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page)
 {
-   return fsg_show_ro(opts->lun, page);
+   return fsg_show_ro(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_ro_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_ro =
-   __CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show,
-   fsg_lun_opts_ro_store);
+CONFIGFS_ATTR(fsg_lun_opts_, ro);
 
-static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_show(struct config_item *item,
   char *page)
 {
-   return fsg_show_removable(opts->lun, page);
+   return fsg_show_removable(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_store(struct config_item *item,
   const char *page, size_t len)
 {
-   return fsg_store_removable(opts->lun, page, len);
+   return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_removable =
-   __CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR,
-   fsg_lun_opts_removable_show,
-   fsg_lun_opts_removable_store);
+CONFIGFS_ATTR(fsg_lun_opts_, removable);
 
-static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page)
 {
-   return fsg_show_cdrom(opts->lun, page);
+   return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opt

[Ocfs2-devel] [PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_phonet.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void phonet_attr_release(struct config_item *item)
 {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)
 
 static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
 };
 
-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
 }
 
-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);
 
 static struct configfs_attribute *phonet_attrs[] = {
-   &f_phonet_ifname.attr,
+   &f_phonet_attr_ifname,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 09/23] usb-gadget/f_printer: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_printer.c | 30 --
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/function/f_printer.c 
b/drivers/usb/gadget/function/f_printer.c
index 8e2b6be..3a37846 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_printer_opts);
-CONFIGFS_ATTR_OPS(f_printer_opts);
-
 static void printer_attr_release(struct config_item *item)
 {
struct f_printer_opts *opts = to_f_printer_opts(item);
@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations printer_item_ops = {
.release= printer_attr_release,
-   .show_attribute = f_printer_opts_attr_show,
-   .store_attribute = f_printer_opts_attr_store,
 };
 
-static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_show(struct config_item *item,
  char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result, l;
 
mutex_lock(&opts->lock);
@@ -1191,14 +1188,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct 
f_printer_opts *opts,
return result;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_pnp_string =
-   __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR,
-   f_printer_opts_pnp_string_show,
-   f_printer_opts_pnp_string_store);
+CONFIGFS_ATTR(f_printer_opts_, pnp_string);
 
-static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_show(struct config_item *item,
 char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1208,9 +1203,10 @@ static ssize_t f_printer_opts_q_len_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_store(struct config_item *item,
  const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int ret;
u16 num;
 
@@ -1231,13 +1227,11 @@ end:
return ret;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_q_len =
-   __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show,
-   f_printer_opts_q_len_store);
+CONFIGFS_ATTR(f_printer_opts_, q_len);
 
 static struct configfs_attribute *printer_attrs[] = {
-   &f_printer_opts_pnp_string.attr,
-   &f_printer_opts_q_len.attr,
+   &f_printer_opts_attr_pnp_string,
+   &f_printer_opts_attr_q_len,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 05/23] usb-gadget/f_acm: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_acm.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void acm_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
 
 static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
 };
 
-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_acm_port_num.attr,
+   &f_acm_port_attr_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 16/23] usb-gadget/f_serial: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_serial.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_serial.c 
b/drivers/usb/gadget/function/f_serial.c
index 1d162e2..ec837f4 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -266,22 +266,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_serial_attr_show(struct config_item *item,
- struct configfs_attribute *attr,
- char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void serial_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -291,19 +275,17 @@ static void serial_attr_release(struct config_item *item)
 
 static struct configfs_item_operations serial_item_ops = {
.release= serial_attr_release,
-   .show_attribute = f_serial_attr_show,
 };
 
-static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_serial_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show);
+CONFIGFS_ATTR_RO(f_serial_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_serial_port_num.attr,
+   &f_serial_attr_port_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] simplify configfs attributes V2

2015-10-03 Thread Christoph Hellwig
This series consolidates the code to implement configfs attributes
by providing the ->show and ->store method in common code and using
container_of in the methods to access the containing structure.

This reduces source and binary size of configfs consumers a lot.

Changes since V1:
 - a couple fixes for unintended changes in the uvc driver
 - moved a few CONFIG_ATTR() statements around
 - fixed up the documentation and samples in the last patch
 - added a little rather pointless blurb to the patch description for
   various patches


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 20/23] netconsole: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
Note that the old code actually used the store_attributes method to do
locking, this is moved into the individual methods.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/netconsole.c | 271 +++
 1 file changed, 132 insertions(+), 139 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 97f3acd..06ee639 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -244,15 +244,6 @@ static void free_param_target(struct netconsole_target *nt)
  * /...
  */
 
-struct netconsole_target_attr {
-   struct configfs_attribute   attr;
-   ssize_t (*show)(struct netconsole_target *nt,
-   char *buf);
-   ssize_t (*store)(struct netconsole_target *nt,
-const char *buf,
-size_t count);
-};
-
 static struct netconsole_target *to_target(struct config_item *item)
 {
return item ?
@@ -264,58 +255,62 @@ static struct netconsole_target *to_target(struct 
config_item *item)
  * Attribute operations for netconsole_target.
  */
 
-static ssize_t show_enabled(struct netconsole_target *nt, char *buf)
+static ssize_t enabled_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled);
 }
 
-static ssize_t show_extended(struct netconsole_target *nt, char *buf)
+static ssize_t extended_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended);
 }
 
-static ssize_t show_dev_name(struct netconsole_target *nt, char *buf)
+static ssize_t dev_name_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name);
+   return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name);
 }
 
-static ssize_t show_local_port(struct netconsole_target *nt, char *buf)
+static ssize_t local_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port);
 }
 
-static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)
+static ssize_t remote_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", 
to_target(item)->np.remote_port);
 }
 
-static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
+static ssize_t local_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
&nt->np.local_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip);
 }
 
-static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
+static ssize_t remote_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
&nt->np.remote_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip);
 }
 
-static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
+static ssize_t local_mac_show(struct config_item *item, char *buf)
 {
-   struct net_device *dev = nt->np.dev;
+   struct net_device *dev = to_target(item)->np.dev;
static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 
};
 
return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast);
 }
 
-static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
+static ssize_t remote_mac_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
+   return snprintf(buf, PAGE_SIZE, "%pM\n", 
to_target(item)->np.remote_mac);
 }
 
 /*
@@ -325,23 +320,26 @@ static ssize_t show_remote_mac(struct netconsole_target 
*nt, char *buf)
  * would enable him to dynamically add new netpoll targets for new
  * network interfaces as and when they come up).
  */
-static ssize_t store_enabled(struct netconsole_target *nt,
-const char *buf,
-size_t count)
+static ssize_t enabled_store(struct config_item *item,
+   const char *buf, size_t count)
 {
+   struct

[Ocfs2-devel] [PATCH 14/23] usb-gadget/f_obex: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_obex.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_obex.c 
b/drivers/usb/gadget/function/f_obex.c
index 5460426..f6f1e6b 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -395,22 +395,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_obex_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void obex_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -420,19 +404,17 @@ static void obex_attr_release(struct config_item *item)
 
 static struct configfs_item_operations obex_item_ops = {
.release= obex_attr_release,
-   .show_attribute = f_obex_attr_show,
 };
 
-static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_obex_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_obex_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show);
+CONFIGFS_ATTR_RO(f_obex_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_obex_port_num.attr,
+   &f_obex_attr_port_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 01/23] configfs: add show and store methods to struct configfs_attribute

2015-10-03 Thread Christoph Hellwig
Add methods to struct configfs_attribute to directly show and store
attributes without adding boilerplate code to every user.  In addition
to the methods this also adds 3 helper macros to define read/write,
read-only and write-only attributes with a single line of code.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Nicholas Bellinger 
Acked-by: Greg Kroah-Hartman 
---
 fs/configfs/file.c   | 17 -
 include/linux/configfs.h | 27 +++
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 403269f..106ca58 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -74,7 +74,11 @@ static int fill_read_buffer(struct dentry * dentry, struct 
configfs_buffer * buf
if (!buffer->page)
return -ENOMEM;
 
-   count = ops->show_attribute(item,attr,buffer->page);
+   if (ops->show_attribute)
+   count = ops->show_attribute(item, attr, buffer->page);
+   else
+   count = attr->show(item, buffer->page);
+
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
if (count >= 0)
@@ -173,7 +177,9 @@ flush_write_buffer(struct dentry * dentry, struct 
configfs_buffer * buffer, size
struct config_item * item = to_item(dentry->d_parent);
struct configfs_item_operations * ops = buffer->ops;
 
-   return ops->store_attribute(item,attr,buffer->page,count);
+   if (ops->store_attribute)
+   return ops->store_attribute(item, attr, buffer->page, count);
+   return attr->store(item, buffer->page, count);
 }
 
 
@@ -237,8 +243,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * and we must have a store method.
 */
if (file->f_mode & FMODE_WRITE) {
-
-   if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute)
+   if (!(inode->i_mode & S_IWUGO) ||
+   (!ops->store_attribute && !attr->store))
goto Eaccess;
 
}
@@ -248,7 +254,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * must be a show method for it.
 */
if (file->f_mode & FMODE_READ) {
-   if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute)
+   if (!(inode->i_mode & S_IRUGO) ||
+   (!ops->show_attribute && !attr->show))
goto Eaccess;
}
 
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 63a36e8..85e9956 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -125,8 +125,35 @@ struct configfs_attribute {
const char  *ca_name;
struct module   *ca_owner;
umode_t ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
 };
 
+#define CONFIGFS_ATTR(_pfx, _name) \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO | S_IWUSR,\
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+   .store  = _pfx##_name##_store,  \
+}
+
+#define CONFIGFS_ATTR_RO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+}
+
+#define CONFIGFS_ATTR_WO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IWUSR,  \
+   .ca_owner   = THIS_MODULE,  \
+   .store  = _pfx##_name##_store,  \
+}
+
 /*
  * Users often need to create attribute structures for their configurable
  * attributes, containing a configfs_attribute member and function pointers
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-28 Thread Christoph Hellwig
On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> this (and the other helper below) could be macros just fine.

They could, but they shouldn't.  Inlines are always preferable over
function-like macros.

> Are you 100% compiler
> will *always* inline these helpers.

With gcc you can't ever be sure - but if it doesn't inline a trivial
pointer arithmetic we'll see breakage in various other places, including
the file system fast path which uses this pattern all over.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 23/23] configfs: remove old API

2015-09-28 Thread Christoph Hellwig
> Haven't you just removed show_attribute() and store_attribute() from
> configfs_item_operations?

Oops, looks like the old text manage to slip back in.  I'll fix it up.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 03/23] usb-gadget/uvc: use per-attribute show and store methods

2015-09-28 Thread Christoph Hellwig
On Mon, Sep 28, 2015 at 01:35:38PM +0200, Andrzej Pietrasiewicz wrote:
>> -#define UVCG_STREAMING_CONTROL_SIZE 1
>
> Moving this define seems an unrelated change to me.

I can move it back - this one wasn't intentional.

>> +#define identity_conv(x) (x)
>
> What is this needed for here?
>
> This #define is not used near the place it is defined.
> Throughout the file the identity_conv is being defined multiple times,
> each time near the place it is used and then undefined.
>
> Without this line the code still compiles.

Looks like a copy & paste erro.  I'll fix it up.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 07/23] usb-gadget/f_loopback: use per-attribute show and store methods

2015-09-28 Thread Christoph Hellwig
On Mon, Sep 28, 2015 at 01:46:57PM +0200, Andrzej Pietrasiewicz wrote:
>>   }
>>
>> -static struct f_lb_opts_attribute f_lb_opts_qlen =
>> -__CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR,
>> -f_lb_opts_qlen_show,
>> -f_lb_opts_qlen_store);
>> -
> In my opinion the below line belongs here:
>
> +CONFIGFS_ATTR(f_lb_opts_, qlen);

The idea is to keep all the attribute defintions near the attribute
array, similar to how most drivers define their sysfs attributes.

If you really don't like that way I'll move it back.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-28 Thread Christoph Hellwig
The Subject line is part of the commit log.  If you have a useful
suggestion for improving the logs please feel free to suggest it.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] simplify configfs attributes

2015-09-26 Thread Christoph Hellwig
On Sat, Sep 26, 2015 at 04:49:06PM -0700, Nicholas A. Bellinger wrote:
> That said, it would probably make sense to merge via target-pending.git
> and get this series into linux-next ASAP.

Sounds good to me!

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/configfs.c   | 295 ++--
 include/linux/usb/gadget_configfs.h |  19 +--
 2 files changed, 118 insertions(+), 196 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 294eb74..163d305 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -64,6 +64,11 @@ struct gadget_info {
char qw_sign[OS_STRING_QW_SIGN_LEN];
 };
 
+static inline struct gadget_info *to_gadget_info(struct config_item *item)
+{
+return container_of(to_config_group(item), struct gadget_info, group);
+}
+
 struct config_usb_cfg {
struct config_group group;
struct config_group strings_group;
@@ -74,6 +79,12 @@ struct config_usb_cfg {
struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
 };
 
+static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item 
*item)
+{
+   return container_of(to_config_group(item), struct config_usb_cfg,
+   group);
+}
+
 struct gadget_strings {
struct usb_gadget_strings stringtab_dev;
struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
@@ -117,32 +128,25 @@ static int usb_string_copy(const char *s, char **s_copy)
return 0;
 }
 
-CONFIGFS_ATTR_STRUCT(gadget_info);
-CONFIGFS_ATTR_STRUCT(config_usb_cfg);
-
-#define GI_DEVICE_DESC_ITEM_ATTR(name) \
-   static struct gadget_info_attribute gadget_cdev_desc_##name = \
-   __CONFIGFS_ATTR(name,  S_IRUGO | S_IWUSR,   \
-   gadget_dev_desc_##name##_show,  \
-   gadget_dev_desc_##name##_store)
-
 #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \
+   return sprintf(page, "0x%02x\n", \
+   to_gadget_info(item)->cdev.desc.__name); \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_R_u16(__name)\
-   static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
 {  \
-   return sprintf(page, "0x%04x\n", le16_to_cpup(&gi->cdev.desc.__name)); \
+   return sprintf(page, "0x%04x\n", \
+   le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \
 }
 
 
 #define GI_DEVICE_DESC_SIMPLE_W_u8(_name)  \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u8 val; \
@@ -150,12 +154,12 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou8(page, 0, &val);  \
if (ret)\
return ret; \
-   gi->cdev.desc._name = val;  \
+   to_gadget_info(item)->cdev.desc._name = val;\
return len; \
 }
 
 #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \
-   static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
+static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len)   \
 {  \
u16 val;\
@@ -163,7 +167,7 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou16(page, 0, &val); \
if (ret)\
return ret; \
-   gi->cdev.desc._name = cpu_to_le16p(&val);   \
+   to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \
return len; \
 }
 
@@ -193,7 +197,7 @@ static ssize_t is_valid_bcd(u16 bcd_val)
return 0;
 }
 
-static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi,
+static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
const char *page, size_t len)
 {
u16 bcdDevice;
@@ -206,11 +210,11 @@ static ssize_t gadget_dev_desc_bcdDevice_store(struct 
gadget_info *gi,
if (ret)
return ret;
 
-   gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
+   to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
return len;
 }
 
-static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi,
+static s

[Ocfs2-devel] [PATCH 16/23] usb-gadget/f_serial: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_serial.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_serial.c 
b/drivers/usb/gadget/function/f_serial.c
index 1d162e2..ec837f4 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -266,22 +266,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_serial_attr_show(struct config_item *item,
- struct configfs_attribute *attr,
- char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void serial_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -291,19 +275,17 @@ static void serial_attr_release(struct config_item *item)
 
 static struct configfs_item_operations serial_item_ops = {
.release= serial_attr_release,
-   .show_attribute = f_serial_attr_show,
 };
 
-static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_serial_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show);
+CONFIGFS_ATTR_RO(f_serial_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_serial_port_num.attr,
+   &f_serial_attr_port_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 09/23] usb-gadget/f_printer: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_printer.c | 31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/function/f_printer.c 
b/drivers/usb/gadget/function/f_printer.c
index 8e2b6be..29c90d5 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_printer_opts);
-CONFIGFS_ATTR_OPS(f_printer_opts);
-
 static void printer_attr_release(struct config_item *item)
 {
struct f_printer_opts *opts = to_f_printer_opts(item);
@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations printer_item_ops = {
.release= printer_attr_release,
-   .show_attribute = f_printer_opts_attr_show,
-   .store_attribute = f_printer_opts_attr_store,
 };
 
-static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_show(struct config_item *item,
  char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_pnp_string_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result, l;
 
mutex_lock(&opts->lock);
@@ -1191,14 +1188,10 @@ static ssize_t f_printer_opts_pnp_string_store(struct 
f_printer_opts *opts,
return result;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_pnp_string =
-   __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR,
-   f_printer_opts_pnp_string_show,
-   f_printer_opts_pnp_string_store);
-
-static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_show(struct config_item *item,
 char *page)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1208,9 +1201,10 @@ static ssize_t f_printer_opts_q_len_show(struct 
f_printer_opts *opts,
return result;
 }
 
-static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts,
+static ssize_t f_printer_opts_q_len_store(struct config_item *item,
  const char *page, size_t len)
 {
+   struct f_printer_opts *opts = to_f_printer_opts(item);
int ret;
u16 num;
 
@@ -1231,13 +1225,12 @@ end:
return ret;
 }
 
-static struct f_printer_opts_attribute f_printer_opts_q_len =
-   __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show,
-   f_printer_opts_q_len_store);
+CONFIGFS_ATTR(f_printer_opts_, pnp_string);
+CONFIGFS_ATTR(f_printer_opts_, q_len);
 
 static struct configfs_attribute *printer_attrs[] = {
-   &f_printer_opts_pnp_string.attr,
-   &f_printer_opts_q_len.attr,
+   &f_printer_opts_attr_pnp_string,
+   &f_printer_opts_attr_q_len,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] simplify configfs attributes

2015-09-25 Thread Christoph Hellwig
Any I promised to Cc Pantelis when posting this for his binary attribute
work but failed to do.  I'm very sorry for that and blame in on the lack
of sleep.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 07/23] usb-gadget/f_loopback: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_loopback.c | 32 
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index 6e2fe63..d4ef421 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -413,9 +413,6 @@ static inline struct f_lb_opts *to_f_lb_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_lb_opts);
-CONFIGFS_ATTR_OPS(f_lb_opts);
-
 static void lb_attr_release(struct config_item *item)
 {
struct f_lb_opts *lb_opts = to_f_lb_opts(item);
@@ -425,12 +422,11 @@ static void lb_attr_release(struct config_item *item)
 
 static struct configfs_item_operations lb_item_ops = {
.release= lb_attr_release,
-   .show_attribute = f_lb_opts_attr_show,
-   .store_attribute= f_lb_opts_attr_store,
 };
 
-static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -440,9 +436,10 @@ static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, 
char *page)
return result;
 }
 
-static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_qlen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -463,13 +460,9 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_qlen =
-   __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR,
-   f_lb_opts_qlen_show,
-   f_lb_opts_qlen_store);
-
-static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page)
+static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -479,9 +472,10 @@ static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts,
+static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
 
@@ -502,14 +496,12 @@ end:
return ret;
 }
 
-static struct f_lb_opts_attribute f_lb_opts_bulk_buflen =
-   __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR,
-   f_lb_opts_bulk_buflen_show,
-   f_lb_opts_bulk_buflen_store);
+CONFIGFS_ATTR(f_lb_opts_, qlen);
+CONFIGFS_ATTR(f_lb_opts_, bulk_buflen);
 
 static struct configfs_attribute *lb_attrs[] = {
-   &f_lb_opts_qlen.attr,
-   &f_lb_opts_bulk_buflen.attr,
+   &f_lb_opts_attr_qlen,
+   &f_lb_opts_attr_bulk_buflen,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 14/23] usb-gadget/f_obex: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_obex.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_obex.c 
b/drivers/usb/gadget/function/f_obex.c
index 5460426..f6f1e6b 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -395,22 +395,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_obex_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-
-   return ret;
-}
-
 static void obex_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -420,19 +404,17 @@ static void obex_attr_release(struct config_item *item)
 
 static struct configfs_item_operations obex_item_ops = {
.release= obex_attr_release,
-   .show_attribute = f_obex_attr_show,
 };
 
-static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_obex_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_obex_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show);
+CONFIGFS_ATTR_RO(f_obex_, port_num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_obex_port_num.attr,
+   &f_obex_attr_port_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_phonet.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void phonet_attr_release(struct config_item *item)
 {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)
 
 static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
 };
 
-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
 }
 
-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);
 
 static struct configfs_attribute *phonet_attrs[] = {
-   &f_phonet_ifname.attr,
+   &f_phonet_attr_ifname,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 12/23] usb-gadget/f_ac1: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_uac1.c | 39 +++-
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac1.c 
b/drivers/usb/gadget/function/f_uac1.c
index 7856b33..ad01032 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -773,9 +773,6 @@ static inline struct f_uac1_opts *to_f_uac1_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac1_opts);
-CONFIGFS_ATTR_OPS(f_uac1_opts);
-
 static void f_uac1_attr_release(struct config_item *item)
 {
struct f_uac1_opts *opts = to_f_uac1_opts(item);
@@ -785,14 +782,13 @@ static void f_uac1_attr_release(struct config_item *item)
 
 static struct configfs_item_operations f_uac1_item_ops = {
.release= f_uac1_attr_release,
-   .show_attribute = f_uac1_opts_attr_show,
-   .store_attribute = f_uac1_opts_attr_store,
 };
 
 #define UAC1_INT_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -802,9 +798,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,
\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret;\
u32 num;\
\
@@ -826,19 +823,17 @@ end:  
\
return ret; \
 }  \
\
-static struct f_uac1_opts_attribute f_uac1_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac1_opts_##name##_show,  \
-   f_uac1_opts_##name##_store)
+CONFIGFS_ATTR(f_uac1_opts_, name)
 
 UAC1_INT_ATTRIBUTE(req_buf_size);
 UAC1_INT_ATTRIBUTE(req_count);
 UAC1_INT_ATTRIBUTE(audio_buf_size);
 
 #define UAC1_STR_ATTRIBUTE(name)   \
-static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
+static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -848,9 +843,10 @@ static ssize_t f_uac1_opts_##name##_show(struct 
f_uac1_opts *opts, \
return result;  \
 }  \
\
-static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts,\
+static ssize_t f_uac1_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac1_opts *opts = to_f_uac1_opts(item);\
int ret = -EBUSY;   \
char *tmp;  \
\
@@ -874,22 

[Ocfs2-devel] [PATCH 10/23] usb-gadget/f_sourcesink: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_sourcesink.c | 88 --
 1 file changed, 36 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c 
b/drivers/usb/gadget/function/f_sourcesink.c
index cbfaf86..e5288c7 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -898,9 +898,6 @@ static inline struct f_ss_opts *to_f_ss_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_ss_opts);
-CONFIGFS_ATTR_OPS(f_ss_opts);
-
 static void ss_attr_release(struct config_item *item)
 {
struct f_ss_opts *ss_opts = to_f_ss_opts(item);
@@ -910,12 +907,11 @@ static void ss_attr_release(struct config_item *item)
 
 static struct configfs_item_operations ss_item_ops = {
.release= ss_attr_release,
-   .show_attribute = f_ss_opts_attr_show,
-   .store_attribute= f_ss_opts_attr_store,
 };
 
-static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -925,9 +921,10 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_pattern_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -953,13 +950,9 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_pattern =
-   __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR,
-   f_ss_opts_pattern_show,
-   f_ss_opts_pattern_store);
-
-static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -969,9 +962,10 @@ static ssize_t f_ss_opts_isoc_interval_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -997,13 +991,9 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_interval =
-   __CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_interval_show,
-   f_ss_opts_isoc_interval_store);
-
-static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char 
*page)
+static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char 
*page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1013,9 +1003,10 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct 
f_ss_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u16 num;
 
@@ -1041,13 +1032,9 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket =
-   __CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_maxpacket_show,
-   f_ss_opts_isoc_maxpacket_store);
-
-static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page)
+static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -1057,9 +1044,10 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts,
+static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item,
   const char *page, size_t len)
 {
+   struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
 
@@ -1085,13 +1073,9 @@ end:
return ret;
 }
 
-static struct f_ss_opts_attribute f_ss_opts_isoc_mult =
-   __CONFIGFS_ATTR(isoc_mult, S_IRUGO | S_IWUSR,
-   f_ss_opts_isoc_mult_show,
-   f_ss_opts_isoc_mult_store);
-
-static ssize_t f_ss_opts_isoc_maxburst_show(struct

[Ocfs2-devel] [PATCH 04/23] usb-gadget/f_hid: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_hid.c | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 6df9715..d15b061 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -713,9 +713,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_hid_opts);
-CONFIGFS_ATTR_OPS(f_hid_opts);
-
 static void hid_attr_release(struct config_item *item)
 {
struct f_hid_opts *opts = to_f_hid_opts(item);
@@ -725,13 +722,12 @@ static void hid_attr_release(struct config_item *item)
 
 static struct configfs_item_operations hidg_item_ops = {
.release= hid_attr_release,
-   .show_attribute = f_hid_opts_attr_show,
-   .store_attribute = f_hid_opts_attr_store,
 };
 
 #define F_HID_OPT(name, prec, limit)   \
-static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
+static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int result; \
\
mutex_lock(&opts->lock);\
@@ -741,9 +737,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts 
*opts, char *page)\
return result;  \
 }  \
\
-static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts,  \
+static ssize_t f_hid_opts_##name##_store(struct config_item *item, \
 const char *page, size_t len)  \
 {  \
+   struct f_hid_opts *opts = to_f_hid_opts(item);  \
int ret;\
u##prec num;\
\
@@ -769,16 +766,15 @@ end:  
\
return ret; \
 }  \
\
-static struct f_hid_opts_attribute f_hid_opts_##name = \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
-   f_hid_opts_##name##_store)
+CONFIGFS_ATTR(f_hid_opts_, name)
 
 F_HID_OPT(subclass, 8, 255);
 F_HID_OPT(protocol, 8, 255);
 F_HID_OPT(report_length, 16, 65535);
 
-static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
+static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char 
*page)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -789,9 +785,10 @@ static ssize_t f_hid_opts_report_desc_show(struct 
f_hid_opts *opts, char *page)
return result;
 }
 
-static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
+static ssize_t f_hid_opts_report_desc_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_hid_opts *opts = to_f_hid_opts(item);
int ret = -EBUSY;
char *d;
 
@@ -818,16 +815,13 @@ end:
return ret;
 }
 
-static struct f_hid_opts_attribute f_hid_opts_report_desc =
-   __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
-   f_hid_opts_report_desc_show,
-   f_hid_opts_report_desc_store);
+CONFIGFS_ATTR(f_hid_opts_, report_desc);
 
 static struct configfs_attribute *hid_attrs[] = {
-   &f_hid_opts_subclass.attr,
-   &f_hid_opts_protocol.attr,
-   &f_hid_opts_report_length.attr,
-   &f_hid_opts_report_desc.attr,
+   &f_hid_opts_attr_subclass,
+   &f_hid_opts_attr_protocol,
+   &f_hid_opts_attr_report_length,
+   &f_hid_opts_attr_report_desc,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 03/23] usb-gadget/uvc: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
UVC is a little different from other configfs consumers in that it wants
different function and field names from the exposed attribute name, so
it keeps it's local macros to define attributes instead of using the common
ones.

Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/uvc_configfs.c | 391 +++--
 1 file changed, 146 insertions(+), 245 deletions(-)

diff --git a/drivers/usb/gadget/function/uvc_configfs.c 
b/drivers/usb/gadget/function/uvc_configfs.c
index 3c0467b..8ae8ff8 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -15,23 +15,27 @@
 #include "u_uvc.h"
 #include "uvc_configfs.h"
 
-#define UVCG_STREAMING_CONTROL_SIZE1
+#define UVC_ATTR(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
+   .store  = prefix##cname##_store,\
+}
 
-#define CONFIGFS_ATTR_OPS_RO(_item)\
-static ssize_t _item##_attr_show(struct config_item *item, \
-struct configfs_attribute *attr,   \
-char *page)\
-{  \
-   struct _item *_item = to_##_item(item); \
-   struct _item##_attribute *_item##_attr =\
-   container_of(attr, struct _item##_attribute, attr); \
-   ssize_t ret = 0;\
-   \
-   if (_item##_attr->show) \
-   ret = _item##_attr->show(_item, page);  \
-   return ret; \
+#define UVC_ATTR_RO(prefix, cname, aname) \
+static struct configfs_attribute prefix##attr_##cname = { \
+   .ca_name= __stringify(aname),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = prefix##cname##_show, \
 }
 
+#define identity_conv(x) (x)
+
+#define UVCG_STREAMING_CONTROL_SIZE1
+
 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item);
 
 /* control/header/ */
@@ -48,18 +52,11 @@ static struct uvcg_control_header 
*to_uvcg_control_header(struct config_item *it
return container_of(item, struct uvcg_control_header, item);
 }
 
-CONFIGFS_ATTR_STRUCT(uvcg_control_header);
-CONFIGFS_ATTR_OPS(uvcg_control_header);
-
-static struct configfs_item_operations uvcg_control_header_item_ops = {
-   .show_attribute = uvcg_control_header_attr_show,
-   .store_attribute= uvcg_control_header_attr_store,
-};
-
 #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit)
\
 static ssize_t uvcg_control_header_##cname##_show( \
-   struct uvcg_control_header *ch, char *page) \
+   struct config_item *item, char *page)   \
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@@ -79,9 +76,10 @@ static ssize_t uvcg_control_header_##cname##_show(   
\
 }  \
\
 static ssize_t \
-uvcg_control_header_##cname##_store(struct uvcg_control_header *ch,\
+uvcg_control_header_##cname##_store(struct config_item *item,  \
   const char *page, size_t len)\
 {  \
+   struct uvcg_control_header *ch = to_uvcg_control_header(item);  \
struct f_uvc_opts *opts;\
struct config_item *opts_item;  \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@@ -115,11 +113,7 @@ end:   

[Ocfs2-devel] simplify configfs attributes

2015-09-25 Thread Christoph Hellwig
This series consolidates the code to implement configfs attributes
by providing the ->show and ->store method in common code and using
container_of in the methods to access the containing structure.

This reduces source and binary size of configfs consumers a lot.


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 01/23] configfs: add show and store methods to struct configfs_attribute

2015-09-25 Thread Christoph Hellwig
Add methods to struct configfs_attribute to directly show and store
attributes without adding boilerplate code to every user.  In addition
to the methods this also adds 3 helper macros to define read/write,
read-only and write-only attributes with a single line of code.

Signed-off-by: Christoph Hellwig 
---
 fs/configfs/file.c   | 17 -
 include/linux/configfs.h | 27 +++
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 403269f..106ca58 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -74,7 +74,11 @@ static int fill_read_buffer(struct dentry * dentry, struct 
configfs_buffer * buf
if (!buffer->page)
return -ENOMEM;
 
-   count = ops->show_attribute(item,attr,buffer->page);
+   if (ops->show_attribute)
+   count = ops->show_attribute(item, attr, buffer->page);
+   else
+   count = attr->show(item, buffer->page);
+
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
if (count >= 0)
@@ -173,7 +177,9 @@ flush_write_buffer(struct dentry * dentry, struct 
configfs_buffer * buffer, size
struct config_item * item = to_item(dentry->d_parent);
struct configfs_item_operations * ops = buffer->ops;
 
-   return ops->store_attribute(item,attr,buffer->page,count);
+   if (ops->store_attribute)
+   return ops->store_attribute(item, attr, buffer->page, count);
+   return attr->store(item, buffer->page, count);
 }
 
 
@@ -237,8 +243,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * and we must have a store method.
 */
if (file->f_mode & FMODE_WRITE) {
-
-   if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute)
+   if (!(inode->i_mode & S_IWUGO) ||
+   (!ops->store_attribute && !attr->store))
goto Eaccess;
 
}
@@ -248,7 +254,8 @@ static int check_perm(struct inode * inode, struct file * 
file)
 * must be a show method for it.
 */
if (file->f_mode & FMODE_READ) {
-   if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute)
+   if (!(inode->i_mode & S_IRUGO) ||
+   (!ops->show_attribute && !attr->show))
goto Eaccess;
}
 
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 63a36e8..85e9956 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -125,8 +125,35 @@ struct configfs_attribute {
const char  *ca_name;
struct module   *ca_owner;
umode_t ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
 };
 
+#define CONFIGFS_ATTR(_pfx, _name) \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO | S_IWUSR,\
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+   .store  = _pfx##_name##_store,  \
+}
+
+#define CONFIGFS_ATTR_RO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IRUGO,  \
+   .ca_owner   = THIS_MODULE,  \
+   .show   = _pfx##_name##_show,   \
+}
+
+#define CONFIGFS_ATTR_WO(_pfx, _name)  \
+static struct configfs_attribute _pfx##attr_##_name = {\
+   .ca_name= __stringify(_name),   \
+   .ca_mode= S_IWUSR,  \
+   .ca_owner   = THIS_MODULE,  \
+   .store  = _pfx##_name##_store,  \
+}
+
 /*
  * Users often need to create attribute structures for their configurable
  * attributes, containing a configfs_attribute member and function pointers
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 23/23] configfs: remove old API

2015-09-25 Thread Christoph Hellwig
Remove the old show_attribute and store_attribute methods and update
the documentation.  Also replace the two C samples with a single new
one in the proper samples directory where people expect to find it.

Signed-off-by: Christoph Hellwig 
---
 Documentation/filesystems/Makefile |   2 -
 Documentation/filesystems/configfs/Makefile|   3 -
 Documentation/filesystems/configfs/configfs.txt|  43 +-
 .../configfs/configfs_example_explicit.c   | 483 -
 .../filesystems/configfs/configfs_example_macros.c | 446 ---
 fs/configfs/file.c |  15 +-
 include/linux/configfs.h   |  82 
 samples/Makefile   |   3 +-
 samples/configfs/Makefile  |   2 +
 samples/configfs/configfs_sample.c | 404 +
 10 files changed, 427 insertions(+), 1056 deletions(-)
 delete mode 100644 Documentation/filesystems/configfs/Makefile
 delete mode 100644 
Documentation/filesystems/configfs/configfs_example_explicit.c
 delete mode 100644 Documentation/filesystems/configfs/configfs_example_macros.c
 create mode 100644 samples/configfs/Makefile
 create mode 100644 samples/configfs/configfs_sample.c

diff --git a/Documentation/filesystems/Makefile 
b/Documentation/filesystems/Makefile
index 13483d1..883010c 100644
--- a/Documentation/filesystems/Makefile
+++ b/Documentation/filesystems/Makefile
@@ -1,5 +1,3 @@
-subdir-y := configfs
-
 # List of programs to build
 hostprogs-y := dnotify_test
 
diff --git a/Documentation/filesystems/configfs/Makefile 
b/Documentation/filesystems/configfs/Makefile
deleted file mode 100644
index be7ec5e..000
--- a/Documentation/filesystems/configfs/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-ifneq ($(CONFIG_CONFIGFS_FS),)
-obj-m += configfs_example_explicit.o configfs_example_macros.o
-endif
diff --git a/Documentation/filesystems/configfs/configfs.txt 
b/Documentation/filesystems/configfs/configfs.txt
index b40fec9..f51d04f 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -160,12 +160,6 @@ among other things.  For that, it needs a type.
 
struct configfs_item_operations {
void (*release)(struct config_item *);
-   ssize_t (*show_attribute)(struct config_item *,
- struct configfs_attribute *,
- char *);
-   ssize_t (*store_attribute)(struct config_item *,
-  struct configfs_attribute *,
-  const char *, size_t);
int (*allow_link)(struct config_item *src,
  struct config_item *target);
int (*drop_link)(struct config_item *src,
@@ -183,9 +177,7 @@ The most basic function of a config_item_type is to define 
what
 operations can be performed on a config_item.  All items that have been
 allocated dynamically will need to provide the ct_item_ops->release()
 method.  This method is called when the config_item's reference count
-reaches zero.  Items that wish to display an attribute need to provide
-the ct_item_ops->show_attribute() method.  Similarly, storing a new
-attribute value uses the store_attribute() method.
+reaches zero.
 
 [struct configfs_attribute]
 
@@ -193,6 +185,8 @@ attribute value uses the store_attribute() method.
char*ca_name;
struct module   *ca_owner;
umode_t  ca_mode;
+   ssize_t (*show)(struct config_item *, char *);
+   ssize_t (*store)(struct config_item *, const char *, size_t);
};
 
 When a config_item wants an attribute to appear as a file in the item's
@@ -202,10 +196,15 @@ config_item_type->ct_attrs.  When the item appears in 
configfs, the
 attribute file will appear with the configfs_attribute->ca_name
 filename.  configfs_attribute->ca_mode specifies the file permissions.
 
-If an attribute is readable and the config_item provides a
-ct_item_ops->show_attribute() method, that method will be called
-whenever userspace asks for a read(2) on the attribute.  The converse
-will happen for write(2).
+Items that wish to display an attribute need to provide
+the ct_item_ops->show_attribute() method.  Similarly, storing a new
+attribute value uses the store_attribute() method.
+
+
+If an attribute is readable and provides a ->show method, that method will
+be called whenever userspace asks for a read(2) on the attribute.  If an
+attribute is writable and provides a ->store  method, that method will be
+be called whenever userspace asks for a write(2) on the attribute.
 
 [struct config_group]
 
@@ -311,20 +310,10 @@ the subsystem must be ready for it.
 [An Example]
 
 The best example of these 

[Ocfs2-devel] [PATCH 20/23] netconsole: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Note that the old code actually used the store_attributes method to do
locking, this is moved into the individual methods.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/netconsole.c | 269 +++
 1 file changed, 131 insertions(+), 138 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 97f3acd..8783169 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -244,15 +244,6 @@ static void free_param_target(struct netconsole_target *nt)
  * /...
  */
 
-struct netconsole_target_attr {
-   struct configfs_attribute   attr;
-   ssize_t (*show)(struct netconsole_target *nt,
-   char *buf);
-   ssize_t (*store)(struct netconsole_target *nt,
-const char *buf,
-size_t count);
-};
-
 static struct netconsole_target *to_target(struct config_item *item)
 {
return item ?
@@ -264,58 +255,62 @@ static struct netconsole_target *to_target(struct 
config_item *item)
  * Attribute operations for netconsole_target.
  */
 
-static ssize_t show_enabled(struct netconsole_target *nt, char *buf)
+static ssize_t enabled_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled);
 }
 
-static ssize_t show_extended(struct netconsole_target *nt, char *buf)
+static ssize_t extended_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended);
 }
 
-static ssize_t show_dev_name(struct netconsole_target *nt, char *buf)
+static ssize_t dev_name_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name);
+   return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name);
 }
 
-static ssize_t show_local_port(struct netconsole_target *nt, char *buf)
+static ssize_t local_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port);
 }
 
-static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)
+static ssize_t remote_port_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port);
+   return snprintf(buf, PAGE_SIZE, "%d\n", 
to_target(item)->np.remote_port);
 }
 
-static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
+static ssize_t local_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
&nt->np.local_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip);
 }
 
-static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
+static ssize_t remote_ip_show(struct config_item *item, char *buf)
 {
+   struct netconsole_target *nt = to_target(item);
+
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", 
&nt->np.remote_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip);
 }
 
-static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
+static ssize_t local_mac_show(struct config_item *item, char *buf)
 {
-   struct net_device *dev = nt->np.dev;
+   struct net_device *dev = to_target(item)->np.dev;
static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 
};
 
return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast);
 }
 
-static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
+static ssize_t remote_mac_show(struct config_item *item, char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
+   return snprintf(buf, PAGE_SIZE, "%pM\n", 
to_target(item)->np.remote_mac);
 }
 
 /*
@@ -325,23 +320,26 @@ static ssize_t show_remote_mac(struct netconsole_target 
*nt, char *buf)
  * would enable him to dynamically add new netpoll targets for new
  * network interfaces as and when they come up).
  */
-static ssize_t store_enabled(struct netconsole_target *nt,
-const char *buf,
-size_t count)
+static ssize_t enabled_store(struct config_item *item,
+   const char *buf, size_t count)
 {
+   struct

[Ocfs2-devel] [PATCH 22/23] ocfs2/cluster: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/heartbeat.c   | 205 +++
 fs/ocfs2/cluster/nodemanager.c | 241 ++---
 2 files changed, 100 insertions(+), 346 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index fa15deb..e404386 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1473,16 +1473,17 @@ static int o2hb_read_block_input(struct o2hb_region 
*reg,
return 0;
 }
 
-static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%u\n", reg->hr_block_bytes);
+   return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes);
 }
 
-static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_block_bytes_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
int status;
unsigned long block_bytes;
unsigned int block_bits;
@@ -1501,16 +1502,17 @@ static ssize_t o2hb_region_block_bytes_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_show(struct config_item *item,
char *page)
 {
-   return sprintf(page, "%llu\n", reg->hr_start_block);
+   return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block);
 }
 
-static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_start_block_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
 
@@ -1526,16 +1528,16 @@ static ssize_t o2hb_region_start_block_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%d\n", reg->hr_blocks);
+   return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks);
 }
 
-static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_blocks_store(struct config_item *item,
const char *page,
size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
unsigned long tmp;
char *p = (char *)page;
 
@@ -1554,13 +1556,12 @@ static ssize_t o2hb_region_blocks_write(struct 
o2hb_region *reg,
return count;
 }
 
-static ssize_t o2hb_region_dev_read(struct o2hb_region *reg,
-   char *page)
+static ssize_t o2hb_region_dev_show(struct config_item *item, char *page)
 {
unsigned int ret = 0;
 
-   if (reg->hr_bdev)
-   ret = sprintf(page, "%s\n", reg->hr_dev_name);
+   if (to_o2hb_region(item)->hr_bdev)
+   ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name);
 
return ret;
 }
@@ -1670,10 +1671,11 @@ out:
 }
 
 /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
-static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
+static ssize_t o2hb_region_dev_store(struct config_item *item,
 const char *page,
 size_t count)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
struct task_struct *hb_task;
long fd;
int sectsize;
@@ -1828,9 +1830,9 @@ out:
return ret;
 }
 
-static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
-  char *page)
+static ssize_t o2hb_region_pid_show(struct config_item *item, char *page)
 {
+   struct o2hb_region *reg = to_o2hb_region(item);
pid_t pid = 0;
 
spin_lock(&o2hb_live_lock);
@@ -1844,92 +1846,23 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region 
*reg,
return sprintf(page, "%u\n", pid);
 }
 
-struct o2hb_region_attribute {
-   struct configfs_attribute attr;
-   ssize_t (*show)(struct o2hb_region *, char *);
-   ssize_t (*store)(struct o2hb_region *, const char *, size_t);
-};
-
-static struct o2hb_region_attribute o2hb_region_attr_block_bytes = {
-   .attr   = { .ca_owner = THIS_MODULE,
-   .ca_name = "

[Ocfs2-devel] [PATCH 17/23] dlm: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/dlm/config.c | 288 +++-
 1 file changed, 74 insertions(+), 214 deletions(-)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index d521bdd..8e294fb 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -61,35 +61,8 @@ static struct config_item *make_node(struct config_group *, 
const char *);
 static void drop_node(struct config_group *, struct config_item *);
 static void release_node(struct config_item *);
 
-static ssize_t show_cluster(struct config_item *i, struct configfs_attribute 
*a,
-   char *buf);
-static ssize_t store_cluster(struct config_item *i,
-struct configfs_attribute *a,
-const char *buf, size_t len);
-static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
-char *buf);
-static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a,
- const char *buf, size_t len);
-static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
-char *buf);
-static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
- const char *buf, size_t len);
-
-static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf);
-static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf,
-   size_t len);
-static ssize_t comm_local_read(struct dlm_comm *cm, char *buf);
-static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
-   size_t len);
-static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf,
-   size_t len);
-static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf);
-static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf);
-static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
-   size_t len);
-static ssize_t node_weight_read(struct dlm_node *nd, char *buf);
-static ssize_t node_weight_write(struct dlm_node *nd, const char *buf,
-   size_t len);
+static struct configfs_attribute *comm_attrs[];
+static struct configfs_attribute *node_attrs[];
 
 struct dlm_cluster {
struct config_group group;
@@ -108,6 +81,12 @@ struct dlm_cluster {
char cl_cluster_name[DLM_LOCKSPACE_LEN];
 };
 
+static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
+{
+   return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
+  NULL;
+}
+
 enum {
CLUSTER_ATTR_TCP_PORT = 0,
CLUSTER_ATTR_BUFFER_SIZE,
@@ -124,33 +103,24 @@ enum {
CLUSTER_ATTR_CLUSTER_NAME,
 };
 
-struct cluster_attribute {
-   struct configfs_attribute attr;
-   ssize_t (*show)(struct dlm_cluster *, char *);
-   ssize_t (*store)(struct dlm_cluster *, const char *, size_t);
-};
-
-static ssize_t cluster_cluster_name_read(struct dlm_cluster *cl, char *buf)
+static ssize_t cluster_cluster_name_show(struct config_item *item, char *buf)
 {
+   struct dlm_cluster *cl = config_item_to_cluster(item);
return sprintf(buf, "%s\n", cl->cl_cluster_name);
 }
 
-static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl,
+static ssize_t cluster_cluster_name_store(struct config_item *item,
  const char *buf, size_t len)
 {
+   struct dlm_cluster *cl = config_item_to_cluster(item);
+
strlcpy(dlm_config.ci_cluster_name, buf,
sizeof(dlm_config.ci_cluster_name));
strlcpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name));
return len;
 }
 
-static struct cluster_attribute cluster_attr_cluster_name = {
-   .attr   = { .ca_owner = THIS_MODULE,
-.ca_name = "cluster_name",
-.ca_mode = S_IRUGO | S_IWUSR },
-   .show   = cluster_cluster_name_read,
-   .store  = cluster_cluster_name_write,
-};
+CONFIGFS_ATTR(cluster_, cluster_name);
 
 static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
   int *info_field, int check_zero,
@@ -175,17 +145,19 @@ static ssize_t cluster_set(struct dlm_cluster *cl, 
unsigned int *cl_field,
 }
 
 #define CLUSTER_ATTR(name, check_zero)\
-static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t 
len) \
+static ssize_t cluster_##name##_store(struct config_item *item, \
+   const char *buf, size_t len) \
 { \
+   struct dlm_cluster *cl = config_item_to_cluster(item);\
return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name, \
   

[Ocfs2-devel] [PATCH 13/23] usb-gadget/f_uac2: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_uac2.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c 
b/drivers/usb/gadget/function/f_uac2.c
index f8de7ea..0a5a1e1 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1445,9 +1445,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_uac2_opts);
-CONFIGFS_ATTR_OPS(f_uac2_opts);
-
 static void f_uac2_attr_release(struct config_item *item)
 {
struct f_uac2_opts *opts = to_f_uac2_opts(item);
@@ -1457,14 +1454,13 @@ static void f_uac2_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations f_uac2_item_ops = {
.release= f_uac2_attr_release,
-   .show_attribute = f_uac2_opts_attr_show,
-   .store_attribute = f_uac2_opts_attr_store,
 };
 
 #define UAC2_ATTRIBUTE(name)   \
-static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \
+static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \
 char *page)\
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -1474,9 +1470,10 @@ static ssize_t f_uac2_opts_##name##_show(struct 
f_uac2_opts *opts,   \
return result;  \
 }  \
\
-static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts,\
+static ssize_t f_uac2_opts_##name##_store(struct config_item *item,\
  const char *page, size_t len) \
 {  \
+   struct f_uac2_opts *opts = to_f_uac2_opts(item);\
int ret;\
u32 num;\
\
@@ -1498,10 +1495,7 @@ end: 
\
return ret; \
 }  \
\
-static struct f_uac2_opts_attribute f_uac2_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR,\
-   f_uac2_opts_##name##_show,  \
-   f_uac2_opts_##name##_store)
+CONFIGFS_ATTR(f_uac2_opts_, name)
 
 UAC2_ATTRIBUTE(p_chmask);
 UAC2_ATTRIBUTE(p_srate);
@@ -1511,12 +1505,12 @@ UAC2_ATTRIBUTE(c_srate);
 UAC2_ATTRIBUTE(c_ssize);
 
 static struct configfs_attribute *f_uac2_attrs[] = {
-   &f_uac2_opts_p_chmask.attr,
-   &f_uac2_opts_p_srate.attr,
-   &f_uac2_opts_p_ssize.attr,
-   &f_uac2_opts_c_chmask.attr,
-   &f_uac2_opts_c_srate.attr,
-   &f_uac2_opts_c_ssize.attr,
+   &f_uac2_opts_attr_p_chmask,
+   &f_uac2_opts_attr_p_srate,
+   &f_uac2_opts_attr_p_ssize,
+   &f_uac2_opts_attr_c_chmask,
+   &f_uac2_opts_attr_c_srate,
+   &f_uac2_opts_attr_c_ssize,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 05/23] usb-gadget/f_acm: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_acm.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void acm_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
 
 static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
 };
 
-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   &f_acm_port_num.attr,
+   &f_acm_port_attr_num,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 21/23] ocfs2/cluster: move locking into attribute store methods

2015-09-25 Thread Christoph Hellwig
The test and separate set bit scheme was racy to start with, so move to do
a test_and_set_bit after doing the earlier error checks inside the actual
store methods.  Also remove the locking for the local attribute which
already has a different scheme to synchronize.

Signed-off-by: Christoph Hellwig 
---
 fs/ocfs2/cluster/nodemanager.c | 54 +++---
 1 file changed, 19 insertions(+), 35 deletions(-)

diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 441c84e..7a398f6 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -188,7 +188,6 @@ enum {
O2NM_NODE_ATTR_NUM = 0,
O2NM_NODE_ATTR_PORT,
O2NM_NODE_ATTR_ADDRESS,
-   O2NM_NODE_ATTR_LOCAL,
 };
 
 static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page,
@@ -197,6 +196,7 @@ static ssize_t o2nm_node_num_write(struct o2nm_node *node, 
const char *page,
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
unsigned long tmp;
char *p = (char *)page;
+   int ret = 0;
 
tmp = simple_strtoul(p, &p, 0);
if (!p || (*p && (*p != '\n')))
@@ -215,15 +215,18 @@ static ssize_t o2nm_node_num_write(struct o2nm_node 
*node, const char *page,
 
write_lock(&cluster->cl_nodes_lock);
if (cluster->cl_nodes[tmp])
-   p = NULL;
+   ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_NUM,
+   &node->nd_set_attributes))
+   ret = -EBUSY;
else  {
cluster->cl_nodes[tmp] = node;
node->nd_num = tmp;
set_bit(tmp, cluster->cl_nodes_bitmap);
}
write_unlock(&cluster->cl_nodes_lock);
-   if (p == NULL)
-   return -EEXIST;
+   if (ret)
+   return ret;
 
return count;
 }
@@ -247,6 +250,8 @@ static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node 
*node,
if (tmp >= (u16)-1)
return -ERANGE;
 
+   if (test_and_set_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))
+   return -EBUSY;
node->nd_ipv4_port = htons(tmp);
 
return count;
@@ -282,6 +287,9 @@ static ssize_t o2nm_node_ipv4_address_write(struct 
o2nm_node *node,
write_lock(&cluster->cl_nodes_lock);
if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent))
ret = -EEXIST;
+   else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS,
+   &node->nd_set_attributes))
+   ret = -EBUSY;
else {
rb_link_node(&node->nd_ip_node, parent, p);
rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree);
@@ -388,24 +396,13 @@ static struct o2nm_node_attribute o2nm_node_attr_local = {
 };
 
 static struct configfs_attribute *o2nm_node_attrs[] = {
-   [O2NM_NODE_ATTR_NUM] = &o2nm_node_attr_num.attr,
-   [O2NM_NODE_ATTR_PORT] = &o2nm_node_attr_ipv4_port.attr,
-   [O2NM_NODE_ATTR_ADDRESS] = &o2nm_node_attr_ipv4_address.attr,
-   [O2NM_NODE_ATTR_LOCAL] = &o2nm_node_attr_local.attr,
+   &o2nm_node_attr_num.attr,
+   &o2nm_node_attr_ipv4_port.attr,
+   &o2nm_node_attr_ipv4_address.attr,
+   &o2nm_node_attr_local.attr,
NULL,
 };
 
-static int o2nm_attr_index(struct configfs_attribute *attr)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) {
-   if (attr == o2nm_node_attrs[i])
-   return i;
-   }
-   BUG();
-   return 0;
-}
-
 static ssize_t o2nm_node_show(struct config_item *item,
  struct configfs_attribute *attr,
  char *page)
@@ -427,24 +424,11 @@ static ssize_t o2nm_node_store(struct config_item *item,
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_node_attribute *o2nm_node_attr =
container_of(attr, struct o2nm_node_attribute, attr);
-   ssize_t ret;
-   int attr_index = o2nm_attr_index(attr);
 
-   if (o2nm_node_attr->store == NULL) {
-   ret = -EINVAL;
-   goto out;
-   }
-
-   if (test_bit(attr_index, &node->nd_set_attributes))
-   return -EBUSY;
-
-   ret = o2nm_node_attr->store(node, page, count);
-   if (ret < count)
-   goto out;
+   if (o2nm_node_attr->store == NULL)
+   return -EINVAL;
 
-   set_bit(attr_index, &node->nd_set_attributes);
-out:
-   return ret;
+   return o2nm_node_attr->store(node, page, count);
 }
 
 static struct configfs_item_operations o2nm_node_item_ops = {
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 18/23] spear13xx_pcie_gadget: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/misc/spear13xx_pcie_gadget.c | 216 ---
 1 file changed, 71 insertions(+), 145 deletions(-)

diff --git a/drivers/misc/spear13xx_pcie_gadget.c 
b/drivers/misc/spear13xx_pcie_gadget.c
index b8374cd..ee120dc 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -220,11 +220,17 @@ static irqreturn_t spear_pcie_gadget_irq(int irq, void 
*dev_id)
 /*
  * configfs interfaces show/store functions
  */
-static ssize_t pcie_gadget_show_link(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+
+static struct pcie_gadget_target *to_target(struct config_item *item)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   return item ?
+   container_of(to_configfs_subsystem(to_config_group(item)),
+   struct pcie_gadget_target, subsys) : NULL;
+}
+
+static ssize_t pcie_gadget_link_show(struct config_item *item, char *buf)
+{
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID))
return sprintf(buf, "UP");
@@ -232,11 +238,10 @@ static ssize_t pcie_gadget_show_link(
return sprintf(buf, "DOWN");
 }
 
-static ssize_t pcie_gadget_store_link(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_link_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
 
if (sysfs_streq(buf, "UP"))
writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID),
@@ -250,17 +255,15 @@ static ssize_t pcie_gadget_store_link(
return count;
 }
 
-static ssize_t pcie_gadget_show_int_type(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf)
 {
-   return sprintf(buf, "%s", config->int_type);
+   return sprintf(buf, "%s", to_target(item)->int_type);
 }
 
-static ssize_t pcie_gadget_store_int_type(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_int_type_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
u32 cap, vec, flags;
ulong vector;
 
@@ -288,11 +291,10 @@ static ssize_t pcie_gadget_store_int_type(
return count;
 }
 
-static ssize_t pcie_gadget_show_no_of_msi(
-   struct spear_pcie_gadget_config *config,
-   char *buf)
+static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct spear_pcie_gadget_config *config = to_target(item)
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
u32 cap, vec, flags;
ulong vector;
 
@@ -313,13 +315,12 @@ static ssize_t pcie_gadget_show_no_of_msi(
return sprintf(buf, "%lu", vector);
 }
 
-static ssize_t pcie_gadget_store_no_of_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
int ret;
 
-   ret = kstrtoul(buf, 0, &config->requested_msi);
+   ret = kstrtoul(buf, 0, &to_target(item)->requested_msi);
if (ret)
return ret;
 
@@ -329,11 +330,10 @@ static ssize_t pcie_gadget_store_no_of_msi(
return count;
 }
 
-static ssize_t pcie_gadget_store_inta(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_inta_store(struct config_item *item,
const char *buf, size_t count)
 {
-   struct pcie_app_reg __iomem *app_reg = config->va_app_base;
+   struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
ulong en;
int ret;
 
@@ -351,10 +351,10 @@ static ssize_t pcie_gadget_store_inta(
return count;
 }
 
-static ssize_t pcie_gadget_store_send_msi(
-   struct spear_pcie_gadget_config *config,
+static ssize_t pcie_gadget_send_msi_store(struct config_item *item,
const char *buf, size_t count)
 {
+   struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
ulong vector;
u32 ven_msi;
@@ -388,19 +388,16 @@ static ssize_t pcie_gadget_store_send_msi(
return count;
 }
 
-static ssize_t pcie_gadget_show_vendor_id(
-   struct spear_pcie_gadget_config *config,
-   char *bu

[Ocfs2-devel] [PATCH 08/23] usb-gadget/f_midi: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_midi.c | 37 
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index a287a48..0e2b8ed 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -906,9 +906,6 @@ static inline struct f_midi_opts *to_f_midi_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_midi_opts);
-CONFIGFS_ATTR_OPS(f_midi_opts);
-
 static void midi_attr_release(struct config_item *item)
 {
struct f_midi_opts *opts = to_f_midi_opts(item);
@@ -918,13 +915,12 @@ static void midi_attr_release(struct config_item *item)
 
 static struct configfs_item_operations midi_item_ops = {
.release= midi_attr_release,
-   .show_attribute = f_midi_opts_attr_show,
-   .store_attribute = f_midi_opts_attr_store,
 };
 
 #define F_MIDI_OPT(name, test_limit, limit)\
-static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) 
\
+static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) 
\
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int result; \
\
mutex_lock(&opts->lock);\
@@ -934,9 +930,10 @@ static ssize_t f_midi_opts_##name##_show(struct 
f_midi_opts *opts, char *page) \
return result;  \
 }  \
\
-static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts,\
+static ssize_t f_midi_opts_##name##_store(struct config_item *item,\
 const char *page, size_t len)  \
 {  \
+   struct f_midi_opts *opts = to_f_midi_opts(item);\
int ret;\
u32 num;\
\
@@ -962,9 +959,7 @@ end:
\
return ret; \
 }  \
\
-static struct f_midi_opts_attribute f_midi_opts_##name =   \
-   __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \
-   f_midi_opts_##name##_store)
+CONFIGFS_ATTR(f_midi_opts_, name);
 
 F_MIDI_OPT(index, true, SNDRV_CARDS);
 F_MIDI_OPT(buflen, false, 0);
@@ -972,8 +967,9 @@ F_MIDI_OPT(qlen, false, 0);
 F_MIDI_OPT(in_ports, true, MAX_PORTS);
 F_MIDI_OPT(out_ports, true, MAX_PORTS);
 
-static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
+static ssize_t f_midi_opts_id_show(struct config_item *item, char *page)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int result;
 
mutex_lock(&opts->lock);
@@ -989,9 +985,10 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts 
*opts, char *page)
return result;
 }
 
-static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts,
+static ssize_t f_midi_opts_id_store(struct config_item *item,
const char *page, size_t len)
 {
+   struct f_midi_opts *opts = to_f_midi_opts(item);
int ret;
char *c;
 
@@ -1016,17 +1013,15 @@ end:
return ret;
 }
 
-static struct f_midi_opts_attribute f_midi_opts_id =
-   __CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show,
-   f_midi_opts_id_store);
+CONFIGFS_ATTR(f_midi_opts_, id);
 
 static struct configfs_attribute *midi_attrs[] = {
-   &f_midi_opts_index.attr,
-   &f_midi_opts_buflen.attr,
-   &f_midi_opts_qlen.attr,
-   &f_midi_opts_in_ports.attr,
-   &f_midi_opts_out_ports.attr,
-   &f_midi_opts_id.attr,
+   &f_midi_opts_attr_index,
+   &f_midi_opts_attr_buflen,
+   &f_midi_opts_attr_qlen,
+   &f_midi_opts_attr_in_ports,
+   &f_midi_opts_attr_out_ports,
+   &f_midi_opts_attr_id,
NULL,
 };
 
-- 
1.9.1


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


[Ocfs2-devel] [PATCH 06/23] usb-gadget/ether: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_ecm.c|  8 ++---
 drivers/usb/gadget/function/f_eem.c|  8 ++---
 drivers/usb/gadget/function/f_ncm.c|  8 ++---
 drivers/usb/gadget/function/f_rndis.c  |  8 ++---
 drivers/usb/gadget/function/f_subset.c |  8 ++---
 drivers/usb/gadget/function/u_ether_configfs.h | 44 +++---
 6 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 7b7424f..0106de8 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -855,10 +855,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
 
 static struct configfs_attribute *ecm_attrs[] = {
-   &f_ecm_opts_dev_addr.attr,
-   &f_ecm_opts_host_addr.attr,
-   &f_ecm_opts_qmult.attr,
-   &f_ecm_opts_ifname.attr,
+   &ecm_opts_attr_dev_addr,
+   &ecm_opts_attr_host_addr,
+   &ecm_opts_attr_qmult,
+   &ecm_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index c9e90de..f965403 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -555,10 +555,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
 
 static struct configfs_attribute *eem_attrs[] = {
-   &f_eem_opts_dev_addr.attr,
-   &f_eem_opts_host_addr.attr,
-   &f_eem_opts_qmult.attr,
-   &f_eem_opts_ifname.attr,
+   &eem_opts_attr_dev_addr,
+   &eem_opts_attr_host_addr,
+   &eem_opts_attr_qmult,
+   &eem_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_ncm.c 
b/drivers/usb/gadget/function/f_ncm.c
index 3f05c6bd..01a99e5 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1503,10 +1503,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
 
 static struct configfs_attribute *ncm_attrs[] = {
-   &f_ncm_opts_dev_addr.attr,
-   &f_ncm_opts_host_addr.attr,
-   &f_ncm_opts_qmult.attr,
-   &f_ncm_opts_ifname.attr,
+   &ncm_opts_attr_dev_addr,
+   &ncm_opts_attr_host_addr,
+   &ncm_opts_attr_qmult,
+   &ncm_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_rndis.c 
b/drivers/usb/gadget/function/f_rndis.c
index 32985da..a04b526 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -878,10 +878,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
 
 static struct configfs_attribute *rndis_attrs[] = {
-   &f_rndis_opts_dev_addr.attr,
-   &f_rndis_opts_host_addr.attr,
-   &f_rndis_opts_qmult.attr,
-   &f_rndis_opts_ifname.attr,
+   &rndis_opts_attr_dev_addr,
+   &rndis_opts_attr_host_addr,
+   &rndis_opts_attr_qmult,
+   &rndis_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/f_subset.c 
b/drivers/usb/gadget/function/f_subset.c
index e3dfa67..055e4ea 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -413,10 +413,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
 
 static struct configfs_attribute *gether_attrs[] = {
-   &f_gether_opts_dev_addr.attr,
-   &f_gether_opts_host_addr.attr,
-   &f_gether_opts_qmult.attr,
-   &f_gether_opts_ifname.attr,
+   &gether_opts_attr_dev_addr,
+   &gether_opts_attr_host_addr,
+   &gether_opts_attr_qmult,
+   &gether_opts_attr_ifname,
NULL,
 };
 
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h 
b/drivers/usb/gadget/function/u_ether_configfs.h
index bcbd301..4f47289 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -17,9 +17,6 @@
 #define __U_ETHER_CONFIGFS_H
 
 #define USB_ETHERNET_CONFIGFS_ITEM(_f_)
\
-   CONFIGFS_ATTR_STRUCT(f_##_f_##_opts);   \
-   CONFIGFS_ATTR_OPS(f_##_f_##_opts);  \
-   \
static void _f_##_attr_release(struct config_item *item)\
{   \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item);  \
@@ -29,14 +26,13 @@
\
static struct configfs_item_operations _f_##_item_ops = {   \
.release= _f_##_attr_rel

[Ocfs2-devel] [PATCH 11/23] usb-gadget/f_mass_storage: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_mass_storage.c | 123 ++-
 1 file changed, 46 insertions(+), 77 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index a6eb537..db71ae9 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3144,9 +3144,6 @@ static inline struct fsg_opts *to_fsg_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(fsg_lun_opts);
-CONFIGFS_ATTR_OPS(fsg_lun_opts);
-
 static void fsg_lun_attr_release(struct config_item *item)
 {
struct fsg_lun_opts *lun_opts;
@@ -3157,110 +3154,89 @@ static void fsg_lun_attr_release(struct config_item 
*item)
 
 static struct configfs_item_operations fsg_lun_item_ops = {
.release= fsg_lun_attr_release,
-   .show_attribute = fsg_lun_opts_attr_show,
-   .store_attribute= fsg_lun_opts_attr_store,
 };
 
-static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page);
 }
 
-static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_file_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_file =
-   __CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show,
-   fsg_lun_opts_file_store);
-
-static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page)
 {
-   return fsg_show_ro(opts->lun, page);
+   return fsg_show_ro(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_ro_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_ro =
-   __CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show,
-   fsg_lun_opts_ro_store);
-
-static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_show(struct config_item *item,
   char *page)
 {
-   return fsg_show_removable(opts->lun, page);
+   return fsg_show_removable(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_removable_store(struct config_item *item,
   const char *page, size_t len)
 {
-   return fsg_store_removable(opts->lun, page, len);
+   return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len);
 }
 
-static struct fsg_lun_opts_attribute fsg_lun_opts_removable =
-   __CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR,
-   fsg_lun_opts_removable_show,
-   fsg_lun_opts_removable_store);
-
-static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page)
+static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page)
 {
-   return fsg_show_cdrom(opts->lun, page);
+   return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page);
 }
 
-static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts,
+static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item,
   const char *page, size_t len)
 {
-   struct fsg_opts *fsg_opts;
-
-   fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
+   struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
+   struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
 
return fsg_store_cdrom(opts->lun, 

Re: [Ocfs2-devel] [PATCH 14/17] quota: Remove ->get_xstate and ->get_xstatev callbacks

2015-01-19 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 12/17] xfs: Convert to using ->get_state callback

2015-01-19 Thread Christoph Hellwig
> +static void xfs_qm_fill_state(struct qc_type_state *tstate,

Normal xfs style would be to keep the "static void " on a separate line,
as well as the arguments, e.g.

static void
xfs_qm_fill_state(
struct qc_type_state*tstate,

>
> +   struct xfs_mount *mp,
> +   struct xfs_inode *ip,
> +   xfs_ino_t ino)

No need to pass mp, as it can be derived as ip->i_mount.

Btw, I think this code should move into xfs_quotaops.c now
that it ties into the Linux quota interface, and xfs_qm_scall_getstate
should be folded into xfs_fs_get_quota_state.


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 11/17] quota: Wire up Q_GETXSTATE and Q_GETXSTATV calls to work with ->get_state

2015-01-19 Thread Christoph Hellwig
Looks good,

Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 10/17] quota: Make VFS quotas use new interface for getting quota info

2015-01-19 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 1/4] quota: Don't store flags for v2 quota format

2015-01-19 Thread Christoph Hellwig
On Thu, Jan 15, 2015 at 11:13:10AM +0100, Jan Kara wrote:
>   Hum, I'm not sure I follow you. Current kernels will store any 32-bit
> number user sets in flags field. So if we wanted to be 100% safe, we'd have
> to just ignore that field. Which isn't currently a problem since quota code
> doesn't use the field for anything (it was added just for future
> extensions). But since I'm pretty certain noone actually relies on values
> of that field, I though we could just get away with forcibly zeroing the
> field now and if there's a need to use the field in a few years, we could
> start using it.

Oh, I misread the code and your description.  I thought we would just
store any potentially valid in-core flag on disk.

I guess for now the best case would be to stop storing anything, and
then just make an educated decision if/when we need a flags field.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 09/17] quota: Make Q_XQUOTASYNC support VFS quota syncing

2015-01-19 Thread Christoph Hellwig
On Fri, Jan 16, 2015 at 01:47:43PM +0100, Jan Kara wrote:
> Call ->quota_sync method from Q_XQUOTASYNC for better userspace
> compatibility.

Q_XQUOTASYNC never did the equivalent to ->quota_sync, but rather was
the equivalent to sys_syncfs which also happens to write out quotas.

Unless you have a really strong reason for wiring it up, I'd rather keep
it as-is.

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 06/17] quota: Remove quota_on_meta callback

2015-01-19 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 02/17] quota: Wire up ->quota_{enable, disable} callbacks into Q_QUOTA{ON, OFF}

2015-01-19 Thread Christoph Hellwig
On Fri, Jan 16, 2015 at 01:47:36PM +0100, Jan Kara wrote:
> Make Q_QUOTAON / Q_QUOTAOFF quotactl call ->quota_enable /
> ->quota_disable callback when provided. To match current behavior of
> ocfs2 & ext4 we make these quotactls turn on / off quota enforcement for
> appropriate quota type.
> 
> Signed-off-by: Jan Kara 
> ---
>  fs/quota/quota.c | 31 +++
>  include/linux/quotaops.h |  2 ++
>  2 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
> index 5b307e2b5719..748716ffee48 100644
> --- a/fs/quota/quota.c
> +++ b/fs/quota/quota.c
> @@ -66,18 +66,43 @@ static int quota_sync_all(int type)
>   return ret;
>  }
>  
> +unsigned int qtype_limit_flag(int type)
> +{
> + switch (type) {
> + case USRQUOTA:
> + return FS_QUOTA_UDQ_ENFD;
> + case GRPQUOTA:
> + return FS_QUOTA_GDQ_ENFD;
> + case PRJQUOTA:
> + return FS_QUOTA_PDQ_ENFD;
> + }
> +     return 0;


What's the limit_ in the name supposed to mean?

Otherwise looks good:

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 03/17] quota: Add ->quota_{enable, disable} callbacks for VFS quotas

2015-01-19 Thread Christoph Hellwig
On Fri, Jan 16, 2015 at 01:47:37PM +0100, Jan Kara wrote:
> +EXPORT_SYMBOL(dquot_quota_enable);

> +EXPORT_SYMBOL(dquot_quota_disable);

I can't find any modular users of this (in fact none outside this
file), so I'd suggest to keep these local.


___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


Re: [Ocfs2-devel] [PATCH 08/17] quota: Store maximum space limit in bytes

2015-01-19 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 

___
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel


  1   2   >