All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 03/18] lustre: fileset: add fileset mount support
Date: Tue, 03 Jul 2018 13:52:37 +1000	[thread overview]
Message-ID: <87zhz90yd6.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <1530573875-20465-4-git-send-email-jsimmons@infradead.org>

On Mon, Jul 02 2018, James Simmons wrote:

> From: Lai Siyao <lsiyao@whamcloud.com>
>
> This patch enables client to mount subdirectory as fileset.
>
> usage: mount -t lustre mgsname:/fsname/subdir /mount/point
>
>  * mdt lookup fileset fid and return to client during mount.
>  * `fid2path` support for fileset.
>

> @@ -2626,7 +2626,10 @@ struct getinfo_fid2path {
>  	__u64	   gf_recno;
>  	__u32	   gf_linkno;
>  	__u32	   gf_pathlen;
> -	char	    gf_path[0];
> +	union {
> +		char		gf_path[0];
> +		struct lu_fid	gf_root_fid[0];
> +	} gf_u;

If you just left the "gf_u" off here, you wouldn't need changes like:

> -		ptr = ori_gf->gf_path;
> +		ptr = ori_gf->gf_u.gf_path;

throughout the code.

I'll probably make this change before applying the patch.
The rest can come afterwards.

>  } __packed;
>  
>  /** path2parent request/reply structures */
> diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h
> index 886e817..bd8fa71 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_disk.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
> @@ -78,6 +78,7 @@ struct lustre_mount_data {
>  	int	lmd_recovery_time_hard;
>  	char      *lmd_dev;	   /* device name */
>  	char      *lmd_profile;    /* client only */
> +	char	*lmd_fileset;	/* mount fileset */

Consistent indenting is so over-rated :-)
I really that there is *nothing* you could have done here to make
the indenting consistent without including irrelevant changes in the
patch, which is generally frowned upon.
This is why it is not unusually to have some clean-up patches first,
so that you functional changes can be applied to clean code.

>  
> +	if (fileset)
> +		req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
> +				     strlen(fileset) + 1);
> +	rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_ROOT);
> +	if (rc) {
> +		ptlrpc_request_free(req);
> +		return rc;
> +	}
>  	mdc_pack_body(req, NULL, 0, 0, -1, 0);
> +	if (fileset) {
> +		char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
> +
> +		memcpy(name, fileset, strlen(fileset));

Why isn't this strcpy()?
I realize that strcpy will add a nul that memcpy doesn't add so if I
could see the length being stored, I would understand.
But above I see the size passed to req_capsule_set_size() includes
the trailing nul.

Am I confused, or is the code confusing?


> @@ -1073,10 +1074,30 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
>  		/* Remove leading /s from fsname */
>  		while (*++s1 == '/')
>  			;
> +		s2 = s1;
> +		while (*s2 != '/' && *s2 != '\0')
> +			s2++;

 s2 = strchrnul(s1, '/');

(I only discovered strchrnul() a few days ago).

>  		/* Freed in lustre_free_lsi */
> -		lmd->lmd_profile = kasprintf(GFP_NOFS, "%s-client", s1);
> +		lmd->lmd_profile = kzalloc(s2 - s1 + 8, GFP_NOFS);
>  		if (!lmd->lmd_profile)
>  			return -ENOMEM;
> +
> +		strncat(lmd->lmd_profile, s1, s2 - s1);
> +		strncat(lmd->lmd_profile, "-client", 7);

  kasprintf(GFP_KERN, "%.*s-client", s2-s1, s1);

??

> +
> +		s1 = s2;
> +		s2 = s1 + strlen(s1) - 1;
> +		/* Remove padding /s from fileset */
> +		while (*s2 == '/')
> +			s2--;
> +		if (s2 > s1) {
> +			lmd->lmd_fileset = kzalloc(s2 - s1 + 2, GFP_NOFS);
> +			if (!lmd->lmd_fileset) {
> +				kfree(lmd->lmd_profile);
> +				return -ENOMEM;
> +			}
> +			strncat(lmd->lmd_fileset, s1, s2 - s1 + 1);

This probably deserves to be kasprintf() too.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/bddfa938/attachment.sig>

  reply	other threads:[~2018-07-03  3:52 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 23:24 [lustre-devel] [PATCH 00/18] lustre: missing updates from lustre 2.9 James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 01/18] lustre: grant: add support for OBD_CONNECT_GRANT_PARAM James Simmons
2018-07-03  3:04   ` NeilBrown
2018-07-03 12:43     ` Patrick Farrell
2018-07-03 21:59       ` NeilBrown
2018-07-06  4:02   ` Cory Spitz
2018-07-06 14:28     ` James Simmons
2018-07-06 14:29     ` James Simmons
2018-07-06 15:12       ` Andreas Dilger
2018-07-06 15:50         ` James Simmons
2018-07-23  0:36       ` NeilBrown
2018-07-02 23:24 ` [lustre-devel] [PATCH 02/18] lustre: ladvise: Add feature of giving file access advices James Simmons
2018-07-03  3:32   ` NeilBrown
2018-07-05 22:01     ` James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 03/18] lustre: fileset: add fileset mount support James Simmons
2018-07-03  3:52   ` NeilBrown [this message]
2018-07-02 23:24 ` [lustre-devel] [PATCH 04/18] lustre: obd: rename md_getstatus() to md_get_root() James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 05/18] lustre: llite: fast read implementation James Simmons
2018-07-03  4:10   ` NeilBrown
2018-07-03 12:46     ` Patrick Farrell
2018-07-03 22:03       ` NeilBrown
2018-07-02 23:24 ` [lustre-devel] [PATCH 06/18] lustre: obd: reserve connection flag OBD_CONNECT2_FILE_SECCTX James Simmons
2018-07-03  4:20   ` NeilBrown
2018-07-02 23:24 ` [lustre-devel] [PATCH 07/18] lustre: llite: restore fd_och when putting lease James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 08/18] lustre: security: send file security context for creates James Simmons
2018-07-03  4:26   ` NeilBrown
2018-07-02 23:24 ` [lustre-devel] [PATCH 09/18] lustre: llite: ladvise protocol changes James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 10/18] lustre: ladvise: Add willread advice support for ladvise James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 11/18] lustre: osc: max_pages_per_rpc should be chunk size aligned James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 12/18] lustre: ladvise: Add dontneed advice support for ladvise James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 13/18] lustre: ptlrpc: properly set "rq_xid" for 4MB IO James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 14/18] lustre: obd: add callback for llog_cat_process_or_fork James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 15/18] lustre: mount: fix lmd_parse() to handle new delimiters James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 16/18] lustre: libcfs: restore original behavior in cfs_str2num_check James Simmons
2018-07-03  4:45   ` NeilBrown
2018-07-05 22:50     ` James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 17/18] lustre: ldlm: reduce mem footprint of ldlm_resource James Simmons
2018-07-02 23:24 ` [lustre-devel] [PATCH 18/18] lustre: update version to 2.8.99 James Simmons
2018-07-03 21:46   ` Andreas Dilger
2018-07-05 22:53     ` James Simmons
2018-07-03  4:57 ` [lustre-devel] [PATCH 00/18] lustre: missing updates from lustre 2.9 NeilBrown

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=87zhz90yd6.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=lustre-devel@lists.lustre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.