* [PATCH] ceph: fix st_nlink stat for directories
@ 2018-05-21 9:27 Luis Henriques
2018-05-21 13:04 ` Yan, Zheng
0 siblings, 1 reply; 2+ messages in thread
From: Luis Henriques @ 2018-05-21 9:27 UTC (permalink / raw)
To: Yan, Zheng, Sage Weil, Ilya Dryomov
Cc: ceph-devel, linux-kernel, Luis Henriques
Currently, calling stat on a cephfs directory returns 1 for st_nlink.
This behaviour has recently changed in the fuse client, as some
applications seem to expect this value to be either 0 (if it's
unlinked) or 2 + number of subdirectories. This behaviour was changed
in the fuse client with commit 67c7e4619188 ("client: use common
interp of st_nlink for dirs").
This patch modifies the kernel client to have a similar behaviour.
Link: https://tracker.ceph.com/issues/23873
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
fs/ceph/inode.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index aa7c5a4ff137..6ad66ef8fd66 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2288,6 +2288,14 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
stat->size = ci->i_files + ci->i_subdirs;
stat->blocks = 0;
stat->blksize = 65536;
+ /*
+ * Some applications rely on the number of st_nlink
+ * value on directories to be either 0 (if unlinked)
+ * or 2 + number of subdirectories.
+ */
+ if (stat->nlink == 1)
+ /* '.' + '..' + subdirs */
+ stat->nlink = 1 + 1 + ci->i_subdirs;
}
}
return err;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ceph: fix st_nlink stat for directories
2018-05-21 9:27 [PATCH] ceph: fix st_nlink stat for directories Luis Henriques
@ 2018-05-21 13:04 ` Yan, Zheng
0 siblings, 0 replies; 2+ messages in thread
From: Yan, Zheng @ 2018-05-21 13:04 UTC (permalink / raw)
To: Luis Henriques; +Cc: Sage Weil, Ilya Dryomov, Ceph Development, linux-kernel
> On May 21, 2018, at 17:27, Luis Henriques <lhenriques@suse.com> wrote:
>
> Currently, calling stat on a cephfs directory returns 1 for st_nlink.
> This behaviour has recently changed in the fuse client, as some
> applications seem to expect this value to be either 0 (if it's
> unlinked) or 2 + number of subdirectories. This behaviour was changed
> in the fuse client with commit 67c7e4619188 ("client: use common
> interp of st_nlink for dirs").
>
> This patch modifies the kernel client to have a similar behaviour.
>
> Link: https://tracker.ceph.com/issues/23873
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> fs/ceph/inode.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index aa7c5a4ff137..6ad66ef8fd66 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2288,6 +2288,14 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
> stat->size = ci->i_files + ci->i_subdirs;
> stat->blocks = 0;
> stat->blksize = 65536;
> + /*
> + * Some applications rely on the number of st_nlink
> + * value on directories to be either 0 (if unlinked)
> + * or 2 + number of subdirectories.
> + */
> + if (stat->nlink == 1)
> + /* '.' + '..' + subdirs */
> + stat->nlink = 1 + 1 + ci->i_subdirs;
> }
> }
> return err;
Applied, thanks.
Yan, Zheng
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-21 13:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 9:27 [PATCH] ceph: fix st_nlink stat for directories Luis Henriques
2018-05-21 13:04 ` Yan, Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®