ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2] ceph: support getting ceph.dir.rsnaps vxattr
@ 2020-08-28  1:28 Yanhu Cao
  2021-04-09  6:13 ` Yanhu Cao
  2021-04-09 12:50 ` Jeff Layton
  0 siblings, 2 replies; 4+ messages in thread
From: Yanhu Cao @ 2020-08-28  1:28 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, ceph-devel, linux-kernel, Yanhu Cao

It's easy to know how many snapshots have been created.

Link: https://tracker.ceph.com/issues/47168
Signed-off-by: Yanhu Cao <gmayyyha@gmail.com>
---
 fs/ceph/inode.c      | 1 +
 fs/ceph/mds_client.c | 9 ++++++++-
 fs/ceph/mds_client.h | 1 +
 fs/ceph/super.h      | 2 +-
 fs/ceph/xattr.c      | 7 +++++++
 5 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 357c937699d5..650cad4b3ecb 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -891,6 +891,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
 			ci->i_rfiles = le64_to_cpu(info->rfiles);
 			ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
 			ci->i_dir_pin = iinfo->dir_pin;
+			ci->i_rsnaps = iinfo->rsnaps;
 			ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
 		}
 	}
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 4a26862d7667..3466845c0179 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -176,6 +176,13 @@ static int parse_reply_info_in(void **p, void *end,
 			memset(&info->snap_btime, 0, sizeof(info->snap_btime));
 		}
 
+		/* snapshot count, remains zero for v<=3 */
+		if (struct_v >= 4) {
+			ceph_decode_64_safe(p, end, info->rsnaps, bad);
+		} else {
+			info->rsnaps = 0;
+		}
+
 		*p = end;
 	} else {
 		if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
@@ -214,7 +221,7 @@ static int parse_reply_info_in(void **p, void *end,
 		}
 
 		info->dir_pin = -ENODATA;
-		/* info->snap_btime remains zero */
+		/* info->snap_btime and info->rsnaps remain zero */
 	}
 	return 0;
 bad:
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index bc9e95937d7c..76f2ed1a7cbf 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -88,6 +88,7 @@ struct ceph_mds_reply_info_in {
 	s32 dir_pin;
 	struct ceph_timespec btime;
 	struct ceph_timespec snap_btime;
+	u64 rsnaps;
 	u64 change_attr;
 };
 
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 4c3c964b1c54..eb108b69da71 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -332,7 +332,7 @@ struct ceph_inode_info {
 
 	/* for dirs */
 	struct timespec64 i_rctime;
-	u64 i_rbytes, i_rfiles, i_rsubdirs;
+	u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
 	u64 i_files, i_subdirs;
 
 	/* quotas */
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 3a733ac33d9b..c7d8ecc3d04b 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -231,6 +231,12 @@ static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
 	return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs);
 }
 
+static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val,
+					  size_t size)
+{
+	return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps);
+}
+
 static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
 					size_t size)
 {
@@ -352,6 +358,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
 	XATTR_RSTAT_FIELD(dir, rentries),
 	XATTR_RSTAT_FIELD(dir, rfiles),
 	XATTR_RSTAT_FIELD(dir, rsubdirs),
+	XATTR_RSTAT_FIELD(dir, rsnaps),
 	XATTR_RSTAT_FIELD(dir, rbytes),
 	XATTR_RSTAT_FIELD(dir, rctime),
 	{
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [v2] ceph: support getting ceph.dir.rsnaps vxattr
  2020-08-28  1:28 [v2] ceph: support getting ceph.dir.rsnaps vxattr Yanhu Cao
@ 2021-04-09  6:13 ` Yanhu Cao
  2021-04-09 12:50 ` Jeff Layton
  1 sibling, 0 replies; 4+ messages in thread
From: Yanhu Cao @ 2021-04-09  6:13 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Ilya Dryomov, ceph-devel, LKML

ping @jeff @Ilya

On Fri, Aug 28, 2020 at 9:29 AM Yanhu Cao <gmayyyha@gmail.com> wrote:
>
> It's easy to know how many snapshots have been created.
>
> Link: https://tracker.ceph.com/issues/47168
> Signed-off-by: Yanhu Cao <gmayyyha@gmail.com>
> ---
>  fs/ceph/inode.c      | 1 +
>  fs/ceph/mds_client.c | 9 ++++++++-
>  fs/ceph/mds_client.h | 1 +
>  fs/ceph/super.h      | 2 +-
>  fs/ceph/xattr.c      | 7 +++++++
>  5 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 357c937699d5..650cad4b3ecb 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -891,6 +891,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
>                         ci->i_rfiles = le64_to_cpu(info->rfiles);
>                         ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
>                         ci->i_dir_pin = iinfo->dir_pin;
> +                       ci->i_rsnaps = iinfo->rsnaps;
>                         ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
>                 }
>         }
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 4a26862d7667..3466845c0179 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -176,6 +176,13 @@ static int parse_reply_info_in(void **p, void *end,
>                         memset(&info->snap_btime, 0, sizeof(info->snap_btime));
>                 }
>
> +               /* snapshot count, remains zero for v<=3 */
> +               if (struct_v >= 4) {
> +                       ceph_decode_64_safe(p, end, info->rsnaps, bad);
> +               } else {
> +                       info->rsnaps = 0;
> +               }
> +
>                 *p = end;
>         } else {
>                 if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
> @@ -214,7 +221,7 @@ static int parse_reply_info_in(void **p, void *end,
>                 }
>
>                 info->dir_pin = -ENODATA;
> -               /* info->snap_btime remains zero */
> +               /* info->snap_btime and info->rsnaps remain zero */
>         }
>         return 0;
>  bad:
> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> index bc9e95937d7c..76f2ed1a7cbf 100644
> --- a/fs/ceph/mds_client.h
> +++ b/fs/ceph/mds_client.h
> @@ -88,6 +88,7 @@ struct ceph_mds_reply_info_in {
>         s32 dir_pin;
>         struct ceph_timespec btime;
>         struct ceph_timespec snap_btime;
> +       u64 rsnaps;
>         u64 change_attr;
>  };
>
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 4c3c964b1c54..eb108b69da71 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -332,7 +332,7 @@ struct ceph_inode_info {
>
>         /* for dirs */
>         struct timespec64 i_rctime;
> -       u64 i_rbytes, i_rfiles, i_rsubdirs;
> +       u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
>         u64 i_files, i_subdirs;
>
>         /* quotas */
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index 3a733ac33d9b..c7d8ecc3d04b 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -231,6 +231,12 @@ static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
>         return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs);
>  }
>
> +static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val,
> +                                         size_t size)
> +{
> +       return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps);
> +}
> +
>  static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
>                                         size_t size)
>  {
> @@ -352,6 +358,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
>         XATTR_RSTAT_FIELD(dir, rentries),
>         XATTR_RSTAT_FIELD(dir, rfiles),
>         XATTR_RSTAT_FIELD(dir, rsubdirs),
> +       XATTR_RSTAT_FIELD(dir, rsnaps),
>         XATTR_RSTAT_FIELD(dir, rbytes),
>         XATTR_RSTAT_FIELD(dir, rctime),
>         {
> --
> 2.24.3 (Apple Git-128)
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v2] ceph: support getting ceph.dir.rsnaps vxattr
  2020-08-28  1:28 [v2] ceph: support getting ceph.dir.rsnaps vxattr Yanhu Cao
  2021-04-09  6:13 ` Yanhu Cao
@ 2021-04-09 12:50 ` Jeff Layton
  2021-04-25  2:08   ` Yanhu Cao
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Layton @ 2021-04-09 12:50 UTC (permalink / raw)
  To: Yanhu Cao; +Cc: idryomov, ceph-devel, linux-kernel

On Fri, 2020-08-28 at 09:28 +0800, Yanhu Cao wrote:
> It's easy to know how many snapshots have been created.
> 
> Link: https://tracker.ceph.com/issues/47168
> Signed-off-by: Yanhu Cao <gmayyyha@gmail.com>
> ---
>  fs/ceph/inode.c      | 1 +
>  fs/ceph/mds_client.c | 9 ++++++++-
>  fs/ceph/mds_client.h | 1 +
>  fs/ceph/super.h      | 2 +-
>  fs/ceph/xattr.c      | 7 +++++++
>  5 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 357c937699d5..650cad4b3ecb 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -891,6 +891,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
>  			ci->i_rfiles = le64_to_cpu(info->rfiles);
>  			ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
>  			ci->i_dir_pin = iinfo->dir_pin;
> +			ci->i_rsnaps = iinfo->rsnaps;
>  			ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
>  		}
>  	}
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 4a26862d7667..3466845c0179 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -176,6 +176,13 @@ static int parse_reply_info_in(void **p, void *end,
>  			memset(&info->snap_btime, 0, sizeof(info->snap_btime));
>  		}
>  
> +		/* snapshot count, remains zero for v<=3 */
> +		if (struct_v >= 4) {
> +			ceph_decode_64_safe(p, end, info->rsnaps, bad);
> +		} else {
> +			info->rsnaps = 0;
> +		}
> +
>  		*p = end;
>  	} else {
>  		if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
> @@ -214,7 +221,7 @@ static int parse_reply_info_in(void **p, void *end,
>  		}
>  
>  		info->dir_pin = -ENODATA;
> -		/* info->snap_btime remains zero */
> +		/* info->snap_btime and info->rsnaps remain zero */
>  	}
>  	return 0;
>  bad:
> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> index bc9e95937d7c..76f2ed1a7cbf 100644
> --- a/fs/ceph/mds_client.h
> +++ b/fs/ceph/mds_client.h
> @@ -88,6 +88,7 @@ struct ceph_mds_reply_info_in {
>  	s32 dir_pin;
>  	struct ceph_timespec btime;
>  	struct ceph_timespec snap_btime;
> +	u64 rsnaps;
>  	u64 change_attr;
>  };
>  
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 4c3c964b1c54..eb108b69da71 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -332,7 +332,7 @@ struct ceph_inode_info {
>  
>  	/* for dirs */
>  	struct timespec64 i_rctime;
> -	u64 i_rbytes, i_rfiles, i_rsubdirs;
> +	u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
>  	u64 i_files, i_subdirs;
>  
>  	/* quotas */
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index 3a733ac33d9b..c7d8ecc3d04b 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -231,6 +231,12 @@ static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
>  	return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs);
>  }
>  
> +static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val,
> +					  size_t size)
> +{
> +	return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps);
> +}
> +
>  static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
>  					size_t size)
>  {
> @@ -352,6 +358,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
>  	XATTR_RSTAT_FIELD(dir, rentries),
>  	XATTR_RSTAT_FIELD(dir, rfiles),
>  	XATTR_RSTAT_FIELD(dir, rsubdirs),
> +	XATTR_RSTAT_FIELD(dir, rsnaps),
>  	XATTR_RSTAT_FIELD(dir, rbytes),
>  	XATTR_RSTAT_FIELD(dir, rctime),
>  	{

Sorry we missed this one Yanhu. In the future, please put [PATCH] in the
subject line in some fashion and we may spot it more easily.

This looks fine to me -- merged into ceph-client/testing branch, though
I did revise the changelog to be a bit more descriptive. Tell me if you
think it needs changes.

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v2] ceph: support getting ceph.dir.rsnaps vxattr
  2021-04-09 12:50 ` Jeff Layton
@ 2021-04-25  2:08   ` Yanhu Cao
  0 siblings, 0 replies; 4+ messages in thread
From: Yanhu Cao @ 2021-04-25  2:08 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Ilya Dryomov, ceph-devel, LKML

On Fri, Apr 9, 2021 at 8:50 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> On Fri, 2020-08-28 at 09:28 +0800, Yanhu Cao wrote:
> > It's easy to know how many snapshots have been created.
> >
> > Link: https://tracker.ceph.com/issues/47168
> > Signed-off-by: Yanhu Cao <gmayyyha@gmail.com>
> > ---
> >  fs/ceph/inode.c      | 1 +
> >  fs/ceph/mds_client.c | 9 ++++++++-
> >  fs/ceph/mds_client.h | 1 +
> >  fs/ceph/super.h      | 2 +-
> >  fs/ceph/xattr.c      | 7 +++++++
> >  5 files changed, 18 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> > index 357c937699d5..650cad4b3ecb 100644
> > --- a/fs/ceph/inode.c
> > +++ b/fs/ceph/inode.c
> > @@ -891,6 +891,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
> >                       ci->i_rfiles = le64_to_cpu(info->rfiles);
> >                       ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
> >                       ci->i_dir_pin = iinfo->dir_pin;
> > +                     ci->i_rsnaps = iinfo->rsnaps;
> >                       ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
> >               }
> >       }
> > diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> > index 4a26862d7667..3466845c0179 100644
> > --- a/fs/ceph/mds_client.c
> > +++ b/fs/ceph/mds_client.c
> > @@ -176,6 +176,13 @@ static int parse_reply_info_in(void **p, void *end,
> >                       memset(&info->snap_btime, 0, sizeof(info->snap_btime));
> >               }
> >
> > +             /* snapshot count, remains zero for v<=3 */
> > +             if (struct_v >= 4) {
> > +                     ceph_decode_64_safe(p, end, info->rsnaps, bad);
> > +             } else {
> > +                     info->rsnaps = 0;
> > +             }
> > +
> >               *p = end;
> >       } else {
> >               if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
> > @@ -214,7 +221,7 @@ static int parse_reply_info_in(void **p, void *end,
> >               }
> >
> >               info->dir_pin = -ENODATA;
> > -             /* info->snap_btime remains zero */
> > +             /* info->snap_btime and info->rsnaps remain zero */
> >       }
> >       return 0;
> >  bad:
> > diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> > index bc9e95937d7c..76f2ed1a7cbf 100644
> > --- a/fs/ceph/mds_client.h
> > +++ b/fs/ceph/mds_client.h
> > @@ -88,6 +88,7 @@ struct ceph_mds_reply_info_in {
> >       s32 dir_pin;
> >       struct ceph_timespec btime;
> >       struct ceph_timespec snap_btime;
> > +     u64 rsnaps;
> >       u64 change_attr;
> >  };
> >
> > diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> > index 4c3c964b1c54..eb108b69da71 100644
> > --- a/fs/ceph/super.h
> > +++ b/fs/ceph/super.h
> > @@ -332,7 +332,7 @@ struct ceph_inode_info {
> >
> >       /* for dirs */
> >       struct timespec64 i_rctime;
> > -     u64 i_rbytes, i_rfiles, i_rsubdirs;
> > +     u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
> >       u64 i_files, i_subdirs;
> >
> >       /* quotas */
> > diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> > index 3a733ac33d9b..c7d8ecc3d04b 100644
> > --- a/fs/ceph/xattr.c
> > +++ b/fs/ceph/xattr.c
> > @@ -231,6 +231,12 @@ static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
> >       return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs);
> >  }
> >
> > +static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val,
> > +                                       size_t size)
> > +{
> > +     return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps);
> > +}
> > +
> >  static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
> >                                       size_t size)
> >  {
> > @@ -352,6 +358,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
> >       XATTR_RSTAT_FIELD(dir, rentries),
> >       XATTR_RSTAT_FIELD(dir, rfiles),
> >       XATTR_RSTAT_FIELD(dir, rsubdirs),
> > +     XATTR_RSTAT_FIELD(dir, rsnaps),
> >       XATTR_RSTAT_FIELD(dir, rbytes),
> >       XATTR_RSTAT_FIELD(dir, rctime),
> >       {
>
> Sorry we missed this one Yanhu. In the future, please put [PATCH] in the
> subject line in some fashion and we may spot it more easily.

OK. will do.

>
> This looks fine to me -- merged into ceph-client/testing branch, though
> I did revise the changelog to be a bit more descriptive. Tell me if you
> think it needs changes.

LGTM.

>
> Thanks!
> --
> Jeff Layton <jlayton@kernel.org>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-25  2:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  1:28 [v2] ceph: support getting ceph.dir.rsnaps vxattr Yanhu Cao
2021-04-09  6:13 ` Yanhu Cao
2021-04-09 12:50 ` Jeff Layton
2021-04-25  2:08   ` Yanhu Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).