Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: pass the mdsc to several helpers

We will use the 'mdsc' to get the global_id in the following commits.

Link: https://tracker.ceph.com/issues/61590
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Xiubo Li and committed by
Ilya Dryomov
197b7d79 5c5f0d2b

+55 -37
+9 -6
fs/ceph/caps.c
··· 1178 1178 } 1179 1179 } 1180 1180 1181 - void ceph_remove_cap(struct ceph_cap *cap, bool queue_release) 1181 + void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, 1182 + bool queue_release) 1182 1183 { 1183 1184 struct ceph_inode_info *ci = cap->ci; 1184 1185 struct ceph_fs_client *fsc; ··· 1343 1342 */ 1344 1343 void __ceph_remove_caps(struct ceph_inode_info *ci) 1345 1344 { 1345 + struct inode *inode = &ci->netfs.inode; 1346 + struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc; 1346 1347 struct rb_node *p; 1347 1348 1348 1349 /* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU) ··· 1354 1351 while (p) { 1355 1352 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); 1356 1353 p = rb_next(p); 1357 - ceph_remove_cap(cap, true); 1354 + ceph_remove_cap(mdsc, cap, true); 1358 1355 } 1359 1356 spin_unlock(&ci->i_ceph_lock); 1360 1357 } ··· 4002 3999 goto out_unlock; 4003 4000 4004 4001 if (target < 0) { 4005 - ceph_remove_cap(cap, false); 4002 + ceph_remove_cap(mdsc, cap, false); 4006 4003 goto out_unlock; 4007 4004 } 4008 4005 ··· 4037 4034 change_auth_cap_ses(ci, tcap->session); 4038 4035 } 4039 4036 } 4040 - ceph_remove_cap(cap, false); 4037 + ceph_remove_cap(mdsc, cap, false); 4041 4038 goto out_unlock; 4042 4039 } else if (tsession) { 4043 4040 /* add placeholder for the export tagert */ ··· 4054 4051 spin_unlock(&mdsc->cap_dirty_lock); 4055 4052 } 4056 4053 4057 - ceph_remove_cap(cap, false); 4054 + ceph_remove_cap(mdsc, cap, false); 4058 4055 goto out_unlock; 4059 4056 } 4060 4057 ··· 4167 4164 ocap->mseq, mds, le32_to_cpu(ph->seq), 4168 4165 le32_to_cpu(ph->mseq)); 4169 4166 } 4170 - ceph_remove_cap(ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE)); 4167 + ceph_remove_cap(mdsc, ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE)); 4171 4168 } 4172 4169 4173 4170 *old_issued = issued;
+2 -2
fs/ceph/debugfs.c
··· 81 81 if (req->r_inode) { 82 82 seq_printf(s, " #%llx", ceph_ino(req->r_inode)); 83 83 } else if (req->r_dentry) { 84 - path = ceph_mdsc_build_path(req->r_dentry, &pathlen, 84 + path = ceph_mdsc_build_path(mdsc, req->r_dentry, &pathlen, 85 85 &pathbase, 0); 86 86 if (IS_ERR(path)) 87 87 path = NULL; ··· 100 100 } 101 101 102 102 if (req->r_old_dentry) { 103 - path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen, 103 + path = ceph_mdsc_build_path(mdsc, req->r_old_dentry, &pathlen, 104 104 &pathbase, 0); 105 105 if (IS_ERR(path)) 106 106 path = NULL;
+1 -1
fs/ceph/dir.c
··· 1226 1226 if (result) { 1227 1227 int pathlen = 0; 1228 1228 u64 base = 0; 1229 - char *path = ceph_mdsc_build_path(dentry, &pathlen, 1229 + char *path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, 1230 1230 &base, 0); 1231 1231 1232 1232 /* mark error on parent + clear complete */
+1 -1
fs/ceph/file.c
··· 574 574 if (result) { 575 575 int pathlen = 0; 576 576 u64 base = 0; 577 - char *path = ceph_mdsc_build_path(req->r_dentry, &pathlen, 577 + char *path = ceph_mdsc_build_path(mdsc, req->r_dentry, &pathlen, 578 578 &base, 0); 579 579 580 580 pr_warn("async create failure path=(%llx)%s result=%d!\n",
+22 -17
fs/ceph/mds_client.c
··· 2126 2126 */ 2127 2127 static int trim_caps_cb(struct inode *inode, int mds, void *arg) 2128 2128 { 2129 + struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); 2129 2130 int *remaining = arg; 2130 2131 struct ceph_inode_info *ci = ceph_inode(inode); 2131 2132 int used, wanted, oissued, mine; ··· 2174 2173 2175 2174 if (oissued) { 2176 2175 /* we aren't the only cap.. just remove us */ 2177 - ceph_remove_cap(cap, true); 2176 + ceph_remove_cap(mdsc, cap, true); 2178 2177 (*remaining)--; 2179 2178 } else { 2180 2179 struct dentry *dentry; ··· 2589 2588 2590 2589 /** 2591 2590 * ceph_mdsc_build_path - build a path string to a given dentry 2591 + * @mdsc: mds client 2592 2592 * @dentry: dentry to which path should be built 2593 2593 * @plen: returned length of string 2594 2594 * @pbase: returned base inode number ··· 2609 2607 * Encode hidden .snap dirs as a double /, i.e. 2610 2608 * foo/.snap/bar -> foo//bar 2611 2609 */ 2612 - char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase, 2613 - int for_wire) 2610 + char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry, 2611 + int *plen, u64 *pbase, int for_wire) 2614 2612 { 2615 2613 struct dentry *cur; 2616 2614 struct inode *inode; ··· 2728 2726 return path + pos; 2729 2727 } 2730 2728 2731 - static int build_dentry_path(struct dentry *dentry, struct inode *dir, 2732 - const char **ppath, int *ppathlen, u64 *pino, 2733 - bool *pfreepath, bool parent_locked) 2729 + static int build_dentry_path(struct ceph_mds_client *mdsc, struct dentry *dentry, 2730 + struct inode *dir, const char **ppath, int *ppathlen, 2731 + u64 *pino, bool *pfreepath, bool parent_locked) 2734 2732 { 2735 2733 char *path; 2736 2734 ··· 2746 2744 return 0; 2747 2745 } 2748 2746 rcu_read_unlock(); 2749 - path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1); 2747 + path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1); 2750 2748 if (IS_ERR(path)) 2751 2749 return PTR_ERR(path); 2752 2750 *ppath = path; ··· 2758 2756 const char **ppath, int *ppathlen, u64 *pino, 2759 2757 bool *pfreepath) 2760 2758 { 2759 + struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); 2761 2760 struct dentry *dentry; 2762 2761 char *path; 2763 2762 ··· 2768 2765 return 0; 2769 2766 } 2770 2767 dentry = d_find_alias(inode); 2771 - path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1); 2768 + path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1); 2772 2769 dput(dentry); 2773 2770 if (IS_ERR(path)) 2774 2771 return PTR_ERR(path); ··· 2781 2778 * request arguments may be specified via an inode *, a dentry *, or 2782 2779 * an explicit ino+path. 2783 2780 */ 2784 - static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry, 2785 - struct inode *rdiri, const char *rpath, 2786 - u64 rino, const char **ppath, int *pathlen, 2787 - u64 *ino, bool *freepath, bool parent_locked) 2781 + static int set_request_path_attr(struct ceph_mds_client *mdsc, struct inode *rinode, 2782 + struct dentry *rdentry, struct inode *rdiri, 2783 + const char *rpath, u64 rino, const char **ppath, 2784 + int *pathlen, u64 *ino, bool *freepath, 2785 + bool parent_locked) 2788 2786 { 2789 2787 int r = 0; 2790 2788 ··· 2794 2790 dout(" inode %p %llx.%llx\n", rinode, ceph_ino(rinode), 2795 2791 ceph_snap(rinode)); 2796 2792 } else if (rdentry) { 2797 - r = build_dentry_path(rdentry, rdiri, ppath, pathlen, ino, 2793 + r = build_dentry_path(mdsc, rdentry, rdiri, ppath, pathlen, ino, 2798 2794 freepath, parent_locked); 2799 2795 dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, 2800 2796 *ppath); ··· 2881 2877 bool old_version = !test_bit(CEPHFS_FEATURE_32BITS_RETRY_FWD, 2882 2878 &session->s_features); 2883 2879 2884 - ret = set_request_path_attr(req->r_inode, req->r_dentry, 2880 + ret = set_request_path_attr(mdsc, req->r_inode, req->r_dentry, 2885 2881 req->r_parent, req->r_path1, req->r_ino1.ino, 2886 2882 &path1, &pathlen1, &ino1, &freepath1, 2887 2883 test_bit(CEPH_MDS_R_PARENT_LOCKED, ··· 2895 2891 if (req->r_old_dentry && 2896 2892 !(req->r_old_dentry->d_flags & DCACHE_DISCONNECTED)) 2897 2893 old_dentry = req->r_old_dentry; 2898 - ret = set_request_path_attr(NULL, old_dentry, 2894 + ret = set_request_path_attr(mdsc, NULL, old_dentry, 2899 2895 req->r_old_dentry_dir, 2900 2896 req->r_path2, req->r_ino2.ino, 2901 2897 &path2, &pathlen2, &ino2, &freepath2, true); ··· 4294 4290 */ 4295 4291 static int reconnect_caps_cb(struct inode *inode, int mds, void *arg) 4296 4292 { 4293 + struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); 4297 4294 union { 4298 4295 struct ceph_mds_cap_reconnect v2; 4299 4296 struct ceph_mds_cap_reconnect_v1 v1; ··· 4312 4307 dentry = d_find_primary(inode); 4313 4308 if (dentry) { 4314 4309 /* set pathbase to parent dir when msg_version >= 2 */ 4315 - path = ceph_mdsc_build_path(dentry, &pathlen, &pathbase, 4310 + path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, &pathbase, 4316 4311 recon_state->msg_version >= 2); 4317 4312 dput(dentry); 4318 4313 if (IS_ERR(path)) { ··· 5667 5662 return; 5668 5663 } 5669 5664 5670 - newmap = ceph_mdsmap_decode(&p, end, ceph_msgr2(mdsc->fsc->client)); 5665 + newmap = ceph_mdsmap_decode(mdsc, &p, end, ceph_msgr2(mdsc->fsc->client)); 5671 5666 if (IS_ERR(newmap)) { 5672 5667 err = PTR_ERR(newmap); 5673 5668 goto bad_unlock;
+2 -1
fs/ceph/mds_client.h
··· 581 581 __putname(path - (PATH_MAX - 1 - len)); 582 582 } 583 583 584 - extern char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base, 584 + extern char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, 585 + struct dentry *dentry, int *plen, u64 *base, 585 586 int for_wire); 586 587 587 588 extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);
+2 -1
fs/ceph/mdsmap.c
··· 114 114 * Ignore any fields we don't care about (there are quite a few of 115 115 * them). 116 116 */ 117 - struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2) 117 + struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p, 118 + void *end, bool msgr2) 118 119 { 119 120 struct ceph_mdsmap *m; 120 121 const void *start = *p;
+10 -6
fs/ceph/snap.c
··· 329 329 /* 330 330 * build the snap context for a given realm. 331 331 */ 332 - static int build_snap_context(struct ceph_snap_realm *realm, 332 + static int build_snap_context(struct ceph_mds_client *mdsc, 333 + struct ceph_snap_realm *realm, 333 334 struct list_head *realm_queue, 334 335 struct list_head *dirty_realms) 335 336 { ··· 426 425 /* 427 426 * rebuild snap context for the given realm and all of its children. 428 427 */ 429 - static void rebuild_snap_realms(struct ceph_snap_realm *realm, 428 + static void rebuild_snap_realms(struct ceph_mds_client *mdsc, 429 + struct ceph_snap_realm *realm, 430 430 struct list_head *dirty_realms) 431 431 { 432 432 LIST_HEAD(realm_queue); ··· 453 451 continue; 454 452 } 455 453 456 - last = build_snap_context(_realm, &realm_queue, dirty_realms); 454 + last = build_snap_context(mdsc, _realm, &realm_queue, 455 + dirty_realms); 457 456 dout("%s %llx %p, %s\n", __func__, _realm->ino, _realm, 458 457 last > 0 ? "is deferred" : !last ? "succeeded" : "failed"); 459 458 ··· 711 708 * Queue cap_snaps for snap writeback for this realm and its children. 712 709 * Called under snap_rwsem, so realm topology won't change. 713 710 */ 714 - static void queue_realm_cap_snaps(struct ceph_snap_realm *realm) 711 + static void queue_realm_cap_snaps(struct ceph_mds_client *mdsc, 712 + struct ceph_snap_realm *realm) 715 713 { 716 714 struct ceph_inode_info *ci; 717 715 struct inode *lastinode = NULL; ··· 859 855 860 856 /* rebuild_snapcs when we reach the _end_ (root) of the trace */ 861 857 if (realm_to_rebuild && p >= e) 862 - rebuild_snap_realms(realm_to_rebuild, &dirty_realms); 858 + rebuild_snap_realms(mdsc, realm_to_rebuild, &dirty_realms); 863 859 864 860 if (!first_realm) 865 861 first_realm = realm; ··· 877 873 realm = list_first_entry(&dirty_realms, struct ceph_snap_realm, 878 874 dirty_item); 879 875 list_del_init(&realm->dirty_item); 880 - queue_realm_cap_snaps(realm); 876 + queue_realm_cap_snaps(mdsc, realm); 881 877 } 882 878 883 879 if (realm_ret)
+2 -1
fs/ceph/super.h
··· 1223 1223 unsigned cap, unsigned seq, u64 realmino, int flags, 1224 1224 struct ceph_cap **new_cap); 1225 1225 extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release); 1226 - extern void ceph_remove_cap(struct ceph_cap *cap, bool queue_release); 1226 + extern void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, 1227 + bool queue_release); 1227 1228 extern void __ceph_remove_caps(struct ceph_inode_info *ci); 1228 1229 extern void ceph_put_cap(struct ceph_mds_client *mdsc, 1229 1230 struct ceph_cap *cap);
+4 -1
include/linux/ceph/mdsmap.h
··· 5 5 #include <linux/bug.h> 6 6 #include <linux/ceph/types.h> 7 7 8 + struct ceph_mds_client; 9 + 8 10 /* 9 11 * mds map - describe servers in the mds cluster. 10 12 * ··· 67 65 } 68 66 69 67 extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m); 70 - struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2); 68 + struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p, 69 + void *end, bool msgr2); 71 70 extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m); 72 71 extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m); 73 72