Commit 2b14864a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ceph-for-5.16-rc6' of git://github.com/ceph/ceph-client

Pull ceph fixes from Ilya Dryomov:
 "An SGID directory handling fix (marked for stable), a metrics
  accounting fix and two fixups to appease static checkers"

* tag 'ceph-for-5.16-rc6' of git://github.com/ceph/ceph-client:
  ceph: fix up non-directory creation in SGID directories
  ceph: initialize pathlen variable in reconnect_caps_cb
  ceph: initialize i_size variable in ceph_sync_read
  ceph: fix duplicate increment of opened_inodes metric
parents d9c1e640 fd84bfdd
...@@ -4350,7 +4350,7 @@ void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count) ...@@ -4350,7 +4350,7 @@ void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count)
{ {
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb); struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb);
int bits = (fmode << 1) | 1; int bits = (fmode << 1) | 1;
bool is_opened = false; bool already_opened = false;
int i; int i;
if (count == 1) if (count == 1)
...@@ -4358,19 +4358,19 @@ void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count) ...@@ -4358,19 +4358,19 @@ void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count)
spin_lock(&ci->i_ceph_lock); spin_lock(&ci->i_ceph_lock);
for (i = 0; i < CEPH_FILE_MODE_BITS; i++) { for (i = 0; i < CEPH_FILE_MODE_BITS; i++) {
if (bits & (1 << i))
ci->i_nr_by_mode[i] += count;
/* /*
* If any of the mode ref is larger than 1, * If any of the mode ref is larger than 0,
* that means it has been already opened by * that means it has been already opened by
* others. Just skip checking the PIN ref. * others. Just skip checking the PIN ref.
*/ */
if (i && ci->i_nr_by_mode[i] > 1) if (i && ci->i_nr_by_mode[i])
is_opened = true; already_opened = true;
if (bits & (1 << i))
ci->i_nr_by_mode[i] += count;
} }
if (!is_opened) if (!already_opened)
percpu_counter_inc(&mdsc->metric.opened_inodes); percpu_counter_inc(&mdsc->metric.opened_inodes);
spin_unlock(&ci->i_ceph_lock); spin_unlock(&ci->i_ceph_lock);
} }
......
...@@ -605,13 +605,25 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, ...@@ -605,13 +605,25 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
in.cap.realm = cpu_to_le64(ci->i_snap_realm->ino); in.cap.realm = cpu_to_le64(ci->i_snap_realm->ino);
in.cap.flags = CEPH_CAP_FLAG_AUTH; in.cap.flags = CEPH_CAP_FLAG_AUTH;
in.ctime = in.mtime = in.atime = iinfo.btime; in.ctime = in.mtime = in.atime = iinfo.btime;
in.mode = cpu_to_le32((u32)mode);
in.truncate_seq = cpu_to_le32(1); in.truncate_seq = cpu_to_le32(1);
in.truncate_size = cpu_to_le64(-1ULL); in.truncate_size = cpu_to_le64(-1ULL);
in.xattr_version = cpu_to_le64(1); in.xattr_version = cpu_to_le64(1);
in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid())); in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid()));
in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_mode & S_ISGID ? if (dir->i_mode & S_ISGID) {
dir->i_gid : current_fsgid())); in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid));
/* Directories always inherit the setgid bit. */
if (S_ISDIR(mode))
mode |= S_ISGID;
else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&
!in_group_p(dir->i_gid) &&
!capable_wrt_inode_uidgid(&init_user_ns, dir, CAP_FSETID))
mode &= ~S_ISGID;
} else {
in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid()));
}
in.mode = cpu_to_le32((u32)mode);
in.nlink = cpu_to_le32(1); in.nlink = cpu_to_le32(1);
in.max_size = cpu_to_le64(lo->stripe_unit); in.max_size = cpu_to_le64(lo->stripe_unit);
...@@ -847,7 +859,7 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to, ...@@ -847,7 +859,7 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
ssize_t ret; ssize_t ret;
u64 off = iocb->ki_pos; u64 off = iocb->ki_pos;
u64 len = iov_iter_count(to); u64 len = iov_iter_count(to);
u64 i_size; u64 i_size = i_size_read(inode);
dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len, dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len,
(file->f_flags & O_DIRECT) ? "O_DIRECT" : ""); (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");
......
...@@ -3683,7 +3683,7 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -3683,7 +3683,7 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap,
struct ceph_pagelist *pagelist = recon_state->pagelist; struct ceph_pagelist *pagelist = recon_state->pagelist;
struct dentry *dentry; struct dentry *dentry;
char *path; char *path;
int pathlen, err; int pathlen = 0, err;
u64 pathbase; u64 pathbase;
u64 snap_follows; u64 snap_follows;
...@@ -3703,7 +3703,6 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -3703,7 +3703,6 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap,
} }
} else { } else {
path = NULL; path = NULL;
pathlen = 0;
pathbase = 0; pathbase = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment