]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ceph: add ceph_sb_to_mdsc helper support to parse the mdsc
authorXiubo Li <xiubli@redhat.com>
Thu, 3 Sep 2020 13:01:39 +0000 (09:01 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 12 Oct 2020 13:29:26 +0000 (15:29 +0200)
This will help simplify the code.

[ jlayton: fix minor merge conflict in quota.c ]

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c
fs/ceph/dir.c
fs/ceph/file.c
fs/ceph/inode.c
fs/ceph/locks.c
fs/ceph/quota.c
fs/ceph/snap.c
fs/ceph/super.h

index 034b3f4fdd3a7f201900298f47b295d5cce7b957..39753e0e0e5a288d8d3e7555ff2ce25d42199e0f 100644 (file)
@@ -1906,9 +1906,8 @@ bool __ceph_should_report_size(struct ceph_inode_info *ci)
 void ceph_check_caps(struct ceph_inode_info *ci, int flags,
                     struct ceph_mds_session *session)
 {
-       struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
        struct inode *inode = &ci->vfs_inode;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        struct ceph_cap *cap;
        u64 flush_tid, oldest_flush_tid;
        int file_wanted, used, cap_used;
index d72e4a12bb69ada4c2b3739521f4d7f834ae23a6..a4d48370b2b3242174c0e65a989404320c0eead6 100644 (file)
@@ -38,8 +38,7 @@ static int __dir_lease_try_check(const struct dentry *dentry);
 static int ceph_d_init(struct dentry *dentry)
 {
        struct ceph_dentry_info *di;
-       struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb);
 
        di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
        if (!di)
@@ -738,7 +737,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
                                  unsigned int flags)
 {
        struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_mds_request *req;
        int op;
        int mask;
@@ -827,8 +826,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
 static int ceph_mknod(struct inode *dir, struct dentry *dentry,
                      umode_t mode, dev_t rdev)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_mds_request *req;
        struct ceph_acl_sec_ctx as_ctx = {};
        int err;
@@ -889,8 +887,7 @@ static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 static int ceph_symlink(struct inode *dir, struct dentry *dentry,
                            const char *dest)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_mds_request *req;
        struct ceph_acl_sec_ctx as_ctx = {};
        int err;
@@ -942,8 +939,7 @@ out:
 
 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_mds_request *req;
        struct ceph_acl_sec_ctx as_ctx = {};
        int err = -EROFS;
@@ -1010,8 +1006,7 @@ out:
 static int ceph_link(struct dentry *old_dentry, struct inode *dir,
                     struct dentry *dentry)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_mds_request *req;
        int err;
 
@@ -1192,8 +1187,7 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
                       struct inode *new_dir, struct dentry *new_dentry,
                       unsigned int flags)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(old_dir->i_sb);
        struct ceph_mds_request *req;
        int op = CEPH_MDS_OP_RENAME;
        int err;
index ed8fbfe3bddc6bd9699588f8a5b4387433604568..762a280b703739c38204168f352ec7877918735d 100644 (file)
@@ -182,8 +182,7 @@ static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty)
 static struct ceph_mds_request *
 prepare_open_request(struct super_block *sb, int flags, int create_mode)
 {
-       struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
-       struct ceph_mds_client *mdsc = fsc->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb);
        struct ceph_mds_request *req;
        int want_auth = USE_ANY_MDS;
        int op = (flags & O_CREAT) ? CEPH_MDS_OP_CREATE : CEPH_MDS_OP_OPEN;
@@ -283,7 +282,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
  */
 int ceph_renew_caps(struct inode *inode, int fmode)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        struct ceph_inode_info *ci = ceph_inode(inode);
        struct ceph_mds_request *req;
        int err, flags, wanted;
@@ -1027,8 +1026,7 @@ static void ceph_aio_complete_req(struct ceph_osd_request *req)
        struct inode *inode = req->r_inode;
        struct ceph_aio_request *aio_req = req->r_priv;
        struct ceph_osd_data *osd_data = osd_req_op_extent_osd_data(req, 0);
-       struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
-       struct ceph_client_metric *metric = &fsc->mdsc->metric;
+       struct ceph_client_metric *metric = &ceph_sb_to_mdsc(inode->i_sb)->metric;
 
        BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_BVECS);
        BUG_ON(!osd_data->num_bvecs);
index d163fa96cb40164a5ff9d6fc3e79ff63d78655a5..1fed0e827eb79766cf396d829aeef19a3f435bc7 100644 (file)
@@ -558,8 +558,7 @@ void ceph_evict_inode(struct inode *inode)
         * caps in i_snap_caps.
         */
        if (ci->i_snap_realm) {
-               struct ceph_mds_client *mdsc =
-                                       ceph_inode_to_client(inode)->mdsc;
+               struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
                if (ceph_snap(inode) == CEPH_NOSNAP) {
                        struct ceph_snap_realm *realm = ci->i_snap_realm;
                        dout(" dropping residual ref to snap realm %p\n",
@@ -739,7 +738,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
                    struct ceph_mds_session *session, int cap_fmode,
                    struct ceph_cap_reservation *caps_reservation)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        struct ceph_mds_reply_inode *info = iinfo->in;
        struct ceph_inode_info *ci = ceph_inode(inode);
        int issued, new_issued, info_caps;
index d6b9166e71e4bba0595387cafa2f19b6d2ca38da..048a435a29beed33a26d23dc9886256ec1c19c80 100644 (file)
@@ -63,7 +63,7 @@ static const struct file_lock_operations ceph_fl_lock_ops = {
 static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode,
                             int cmd, u8 wait, struct file_lock *fl)
 {
-       struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        struct ceph_mds_request *req;
        int err;
        u64 length = 0;
index cc2c4d40b0222f77114666410c3fcc30350dd1b0..83cb4f26b689b3bddc3f2959495aa5aff13067e8 100644 (file)
@@ -12,7 +12,7 @@
 
 void ceph_adjust_quota_realms_count(struct inode *inode, bool inc)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        if (inc)
                atomic64_inc(&mdsc->quotarealms_count);
        else
@@ -21,8 +21,8 @@ void ceph_adjust_quota_realms_count(struct inode *inode, bool inc)
 
 static inline bool ceph_has_realms_with_quotas(struct inode *inode)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
-       struct super_block *sb = mdsc->fsc->sb;
+       struct super_block *sb = inode->i_sb;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb);
        struct inode *root = d_inode(sb->s_root);
 
        if (atomic64_read(&mdsc->quotarealms_count) > 0)
@@ -266,7 +266,7 @@ restart:
 
 static bool ceph_quota_is_same_realm(struct inode *old, struct inode *new)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(old)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(old->i_sb);
        struct ceph_snap_realm *old_realm, *new_realm;
        bool is_same;
 
@@ -313,7 +313,7 @@ enum quota_check_op {
 static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
                                 loff_t delta)
 {
-       struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
        struct ceph_inode_info *ci;
        struct ceph_snap_realm *realm, *next;
        struct inode *in;
index 923be9399b21ce7a7feb48d3c471d5fa77fed1fd..0da39c16dab49312f45a6c0f69cc8211fb43cc45 100644 (file)
@@ -602,7 +602,7 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
                            struct ceph_cap_snap *capsnap)
 {
        struct inode *inode = &ci->vfs_inode;
-       struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
 
        BUG_ON(capsnap->writing);
        capsnap->size = inode->i_size;
index a3995ebe0623e950e4d1266b348d72f8ce3b3768..483a52d281cdcfef9f29295e721c36b20bafe530 100644 (file)
@@ -451,6 +451,12 @@ ceph_sb_to_client(const struct super_block *sb)
        return (struct ceph_fs_client *)sb->s_fs_info;
 }
 
+static inline struct ceph_mds_client *
+ceph_sb_to_mdsc(const struct super_block *sb)
+{
+       return (struct ceph_mds_client *)ceph_sb_to_client(sb)->mdsc;
+}
+
 static inline struct ceph_vino
 ceph_vino(const struct inode *inode)
 {