Linux userland API discussions
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Krzysztof Opasiak <k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: balbi-l0cyMroinI0@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org,
	andrzej.p-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
	m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 1/4] fs: configfs: Add unlocked version of configfs_depend_item()
Date: Tue, 28 Apr 2015 11:52:49 -0500	[thread overview]
Message-ID: <20150428165249.GJ18263@saruman.tx.rr.com> (raw)
In-Reply-To: <1428596290-23637-2-git-send-email-k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 3016 bytes --]

Hi,

On Thu, Apr 09, 2015 at 06:18:07PM +0200, Krzysztof Opasiak wrote:
> Sometimes it might be desirable to prohibit removing a directory
> in configfs. One example is USB gadget (mass_storage function):
> when gadget is already bound, if lun directory is removed,
> the gadget must be thrown away, too. A better solution would be
> to fail with e.g. -EBUSY.
> 
> Currently configfs has configfs_depend/undepend_item() methods
> but they cannot be used in configfs callbacks. This commit
> adds unlocked version of this methods which can be used
> only in configfs callbacks.
> 
> Signed-off-by: Krzysztof Opasiak <k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Joel, any comments to this patch ?

> ---
>  fs/configfs/dir.c        |   29 +++++++++++++++++++++++++++++
>  include/linux/configfs.h |    9 +++++++++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index cf0db00..7875a5e 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1152,6 +1152,35 @@ void configfs_undepend_item(struct configfs_subsystem *subsys,
>  }
>  EXPORT_SYMBOL(configfs_undepend_item);
>  
> +int configfs_depend_item_unlocked(struct config_item *target)
> +{
> +	struct configfs_dirent *sd;
> +	int ret = -ENOENT;
> +
> +	spin_lock(&configfs_dirent_lock);
> +	BUG_ON(!target->ci_dentry);
> +
> +	sd = target->ci_dentry->d_fsdata;
> +	if ((sd->s_type & CONFIGFS_DIR) &&
> +	    ((sd->s_type & CONFIGFS_USET_DROPPING) ||
> +	     (sd->s_type & CONFIGFS_USET_CREATING)))
> +		goto out_unlock_dirent_lock;
> +
> +	sd->s_dependent_count += 1;
> +	ret = 0;
> +
> +out_unlock_dirent_lock:
> +	spin_unlock(&configfs_dirent_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL(configfs_depend_item_unlocked);
> +
> +void configfs_undepend_item_unlocked(struct config_item *target)
> +{
> +	configfs_undepend_item(NULL, target);
> +}
> +EXPORT_SYMBOL(configfs_undepend_item_unlocked);
> +
>  static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  {
>  	int ret = 0;
> diff --git a/include/linux/configfs.h b/include/linux/configfs.h
> index 34025df..e9dbf01 100644
> --- a/include/linux/configfs.h
> +++ b/include/linux/configfs.h
> @@ -257,4 +257,13 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
>  int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);
>  void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target);
>  
> +/*
> + * These functions can sleep and can alloc with GFP_KERNEL
> + * NOTE: These should be called only underneath configfs callbacks.
> + * WARNING: These cannot be called on newly created item
> + *        (in make_group()/make_item callback)
> + */
> +int configfs_depend_item_unlocked(struct config_item *target);
> +void configfs_undepend_item_unlocked(struct config_item *target);
> +
>  #endif /* _CONFIGFS_H_ */
> -- 
> 1.7.9.5
> 

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-04-28 16:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 16:18 [PATCH v3 0/4] Ensure that lun ids are contiguous Krzysztof Opasiak
2015-04-09 16:18 ` [PATCH v3 2/4] usb: gadget: mass_storage: Store lun_opts in fsg_opts Krzysztof Opasiak
2015-04-09 16:18 ` [PATCH v3 3/4] usb: gadget: mass_storage: Ensure that lun ids are contiguous Krzysztof Opasiak
     [not found] ` <1428596290-23637-1-git-send-email-k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-04-09 16:18   ` [PATCH v3 1/4] fs: configfs: Add unlocked version of configfs_depend_item() Krzysztof Opasiak
     [not found]     ` <1428596290-23637-2-git-send-email-k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-04-28 16:52       ` Felipe Balbi [this message]
2015-04-09 16:18   ` [PATCH v3 4/4] Documentation: ABI: Fix documentation for mass_storage function Krzysztof Opasiak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150428165249.GJ18263@saruman.tx.rr.com \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=andrzej.p-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org \
    --cc=k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox