ceph: fix incorrectly showing the .snap size for stat
We should set the 'stat->size' to the real number of snapshots for snapdirs. Link: https://tracker.ceph.com/issues/57342 Signed-off-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
bd04b9192e
commit
aa87052dd9
1 changed files with 23 additions and 4 deletions
|
@ -2449,6 +2449,7 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
|
||||||
struct kstat *stat, u32 request_mask, unsigned int flags)
|
struct kstat *stat, u32 request_mask, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct inode *inode = d_inode(path->dentry);
|
struct inode *inode = d_inode(path->dentry);
|
||||||
|
struct super_block *sb = inode->i_sb;
|
||||||
struct ceph_inode_info *ci = ceph_inode(inode);
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
||||||
u32 valid_mask = STATX_BASIC_STATS;
|
u32 valid_mask = STATX_BASIC_STATS;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -2478,16 +2479,34 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ceph_snap(inode) == CEPH_NOSNAP)
|
if (ceph_snap(inode) == CEPH_NOSNAP)
|
||||||
stat->dev = inode->i_sb->s_dev;
|
stat->dev = sb->s_dev;
|
||||||
else
|
else
|
||||||
stat->dev = ci->i_snapid_map ? ci->i_snapid_map->dev : 0;
|
stat->dev = ci->i_snapid_map ? ci->i_snapid_map->dev : 0;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
if (ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb),
|
if (ceph_test_mount_opt(ceph_sb_to_client(sb), RBYTES)) {
|
||||||
RBYTES))
|
|
||||||
stat->size = ci->i_rbytes;
|
stat->size = ci->i_rbytes;
|
||||||
|
} else if (ceph_snap(inode) == CEPH_SNAPDIR) {
|
||||||
|
struct ceph_inode_info *pci;
|
||||||
|
struct ceph_snap_realm *realm;
|
||||||
|
struct inode *parent;
|
||||||
|
|
||||||
|
parent = ceph_lookup_inode(sb, ceph_ino(inode));
|
||||||
|
if (!parent)
|
||||||
|
return PTR_ERR(parent);
|
||||||
|
|
||||||
|
pci = ceph_inode(parent);
|
||||||
|
spin_lock(&pci->i_ceph_lock);
|
||||||
|
realm = pci->i_snap_realm;
|
||||||
|
if (realm)
|
||||||
|
stat->size = realm->num_snaps;
|
||||||
else
|
else
|
||||||
|
stat->size = 0;
|
||||||
|
spin_unlock(&pci->i_ceph_lock);
|
||||||
|
iput(parent);
|
||||||
|
} else {
|
||||||
stat->size = ci->i_files + ci->i_subdirs;
|
stat->size = ci->i_files + ci->i_subdirs;
|
||||||
|
}
|
||||||
stat->blocks = 0;
|
stat->blocks = 0;
|
||||||
stat->blksize = 65536;
|
stat->blksize = 65536;
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue