Skip to content

Commit 197b7d7

Browse files
lxbszidryomov
authored andcommitted
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>
1 parent 5c5f0d2 commit 197b7d7

File tree

10 files changed

+55
-37
lines changed

10 files changed

+55
-37
lines changed

fs/ceph/caps.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,8 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
11781178
}
11791179
}
11801180

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)
11821183
{
11831184
struct ceph_inode_info *ci = cap->ci;
11841185
struct ceph_fs_client *fsc;
@@ -1342,6 +1343,8 @@ static void encode_cap_msg(struct ceph_msg *msg, struct cap_msg_args *arg)
13421343
*/
13431344
void __ceph_remove_caps(struct ceph_inode_info *ci)
13441345
{
1346+
struct inode *inode = &ci->netfs.inode;
1347+
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
13451348
struct rb_node *p;
13461349

13471350
/* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU)
@@ -1351,7 +1354,7 @@ void __ceph_remove_caps(struct ceph_inode_info *ci)
13511354
while (p) {
13521355
struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
13531356
p = rb_next(p);
1354-
ceph_remove_cap(cap, true);
1357+
ceph_remove_cap(mdsc, cap, true);
13551358
}
13561359
spin_unlock(&ci->i_ceph_lock);
13571360
}
@@ -3999,7 +4002,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
39994002
goto out_unlock;
40004003

40014004
if (target < 0) {
4002-
ceph_remove_cap(cap, false);
4005+
ceph_remove_cap(mdsc, cap, false);
40034006
goto out_unlock;
40044007
}
40054008

@@ -4034,7 +4037,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
40344037
change_auth_cap_ses(ci, tcap->session);
40354038
}
40364039
}
4037-
ceph_remove_cap(cap, false);
4040+
ceph_remove_cap(mdsc, cap, false);
40384041
goto out_unlock;
40394042
} else if (tsession) {
40404043
/* add placeholder for the export tagert */
@@ -4051,7 +4054,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
40514054
spin_unlock(&mdsc->cap_dirty_lock);
40524055
}
40534056

4054-
ceph_remove_cap(cap, false);
4057+
ceph_remove_cap(mdsc, cap, false);
40554058
goto out_unlock;
40564059
}
40574060

@@ -4164,7 +4167,7 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,
41644167
ocap->mseq, mds, le32_to_cpu(ph->seq),
41654168
le32_to_cpu(ph->mseq));
41664169
}
4167-
ceph_remove_cap(ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE));
4170+
ceph_remove_cap(mdsc, ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE));
41684171
}
41694172

41704173
*old_issued = issued;

fs/ceph/debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int mdsc_show(struct seq_file *s, void *p)
8181
if (req->r_inode) {
8282
seq_printf(s, " #%llx", ceph_ino(req->r_inode));
8383
} 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,
8585
&pathbase, 0);
8686
if (IS_ERR(path))
8787
path = NULL;
@@ -100,7 +100,7 @@ static int mdsc_show(struct seq_file *s, void *p)
100100
}
101101

102102
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,
104104
&pathbase, 0);
105105
if (IS_ERR(path))
106106
path = NULL;

fs/ceph/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ static void ceph_async_unlink_cb(struct ceph_mds_client *mdsc,
12261226
if (result) {
12271227
int pathlen = 0;
12281228
u64 base = 0;
1229-
char *path = ceph_mdsc_build_path(dentry, &pathlen,
1229+
char *path = ceph_mdsc_build_path(mdsc, dentry, &pathlen,
12301230
&base, 0);
12311231

12321232
/* mark error on parent + clear complete */

fs/ceph/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static void ceph_async_create_cb(struct ceph_mds_client *mdsc,
574574
if (result) {
575575
int pathlen = 0;
576576
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,
578578
&base, 0);
579579

580580
pr_warn("async create failure path=(%llx)%s result=%d!\n",

fs/ceph/mds_client.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,7 @@ static bool drop_negative_children(struct dentry *dentry)
21262126
*/
21272127
static int trim_caps_cb(struct inode *inode, int mds, void *arg)
21282128
{
2129+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
21292130
int *remaining = arg;
21302131
struct ceph_inode_info *ci = ceph_inode(inode);
21312132
int used, wanted, oissued, mine;
@@ -2173,7 +2174,7 @@ static int trim_caps_cb(struct inode *inode, int mds, void *arg)
21732174

21742175
if (oissued) {
21752176
/* we aren't the only cap.. just remove us */
2176-
ceph_remove_cap(cap, true);
2177+
ceph_remove_cap(mdsc, cap, true);
21772178
(*remaining)--;
21782179
} else {
21792180
struct dentry *dentry;
@@ -2588,6 +2589,7 @@ static u8 *get_fscrypt_altname(const struct ceph_mds_request *req, u32 *plen)
25882589

25892590
/**
25902591
* ceph_mdsc_build_path - build a path string to a given dentry
2592+
* @mdsc: mds client
25912593
* @dentry: dentry to which path should be built
25922594
* @plen: returned length of string
25932595
* @pbase: returned base inode number
@@ -2607,8 +2609,8 @@ static u8 *get_fscrypt_altname(const struct ceph_mds_request *req, u32 *plen)
26072609
* Encode hidden .snap dirs as a double /, i.e.
26082610
* foo/.snap/bar -> foo//bar
26092611
*/
2610-
char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase,
2611-
int for_wire)
2612+
char *ceph_mdsc_build_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
2613+
int *plen, u64 *pbase, int for_wire)
26122614
{
26132615
struct dentry *cur;
26142616
struct inode *inode;
@@ -2726,9 +2728,9 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *pbase,
27262728
return path + pos;
27272729
}
27282730

2729-
static int build_dentry_path(struct dentry *dentry, struct inode *dir,
2730-
const char **ppath, int *ppathlen, u64 *pino,
2731-
bool *pfreepath, bool parent_locked)
2731+
static int build_dentry_path(struct ceph_mds_client *mdsc, struct dentry *dentry,
2732+
struct inode *dir, const char **ppath, int *ppathlen,
2733+
u64 *pino, bool *pfreepath, bool parent_locked)
27322734
{
27332735
char *path;
27342736

@@ -2744,7 +2746,7 @@ static int build_dentry_path(struct dentry *dentry, struct inode *dir,
27442746
return 0;
27452747
}
27462748
rcu_read_unlock();
2747-
path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
2749+
path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1);
27482750
if (IS_ERR(path))
27492751
return PTR_ERR(path);
27502752
*ppath = path;
@@ -2756,6 +2758,7 @@ static int build_inode_path(struct inode *inode,
27562758
const char **ppath, int *ppathlen, u64 *pino,
27572759
bool *pfreepath)
27582760
{
2761+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
27592762
struct dentry *dentry;
27602763
char *path;
27612764

@@ -2765,7 +2768,7 @@ static int build_inode_path(struct inode *inode,
27652768
return 0;
27662769
}
27672770
dentry = d_find_alias(inode);
2768-
path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
2771+
path = ceph_mdsc_build_path(mdsc, dentry, ppathlen, pino, 1);
27692772
dput(dentry);
27702773
if (IS_ERR(path))
27712774
return PTR_ERR(path);
@@ -2778,10 +2781,11 @@ static int build_inode_path(struct inode *inode,
27782781
* request arguments may be specified via an inode *, a dentry *, or
27792782
* an explicit ino+path.
27802783
*/
2781-
static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
2782-
struct inode *rdiri, const char *rpath,
2783-
u64 rino, const char **ppath, int *pathlen,
2784-
u64 *ino, bool *freepath, bool parent_locked)
2784+
static int set_request_path_attr(struct ceph_mds_client *mdsc, struct inode *rinode,
2785+
struct dentry *rdentry, struct inode *rdiri,
2786+
const char *rpath, u64 rino, const char **ppath,
2787+
int *pathlen, u64 *ino, bool *freepath,
2788+
bool parent_locked)
27852789
{
27862790
int r = 0;
27872791

@@ -2790,7 +2794,7 @@ static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
27902794
dout(" inode %p %llx.%llx\n", rinode, ceph_ino(rinode),
27912795
ceph_snap(rinode));
27922796
} else if (rdentry) {
2793-
r = build_dentry_path(rdentry, rdiri, ppath, pathlen, ino,
2797+
r = build_dentry_path(mdsc, rdentry, rdiri, ppath, pathlen, ino,
27942798
freepath, parent_locked);
27952799
dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen,
27962800
*ppath);
@@ -2877,7 +2881,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
28772881
bool old_version = !test_bit(CEPHFS_FEATURE_32BITS_RETRY_FWD,
28782882
&session->s_features);
28792883

2880-
ret = set_request_path_attr(req->r_inode, req->r_dentry,
2884+
ret = set_request_path_attr(mdsc, req->r_inode, req->r_dentry,
28812885
req->r_parent, req->r_path1, req->r_ino1.ino,
28822886
&path1, &pathlen1, &ino1, &freepath1,
28832887
test_bit(CEPH_MDS_R_PARENT_LOCKED,
@@ -2891,7 +2895,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
28912895
if (req->r_old_dentry &&
28922896
!(req->r_old_dentry->d_flags & DCACHE_DISCONNECTED))
28932897
old_dentry = req->r_old_dentry;
2894-
ret = set_request_path_attr(NULL, old_dentry,
2898+
ret = set_request_path_attr(mdsc, NULL, old_dentry,
28952899
req->r_old_dentry_dir,
28962900
req->r_path2, req->r_ino2.ino,
28972901
&path2, &pathlen2, &ino2, &freepath2, true);
@@ -4290,6 +4294,7 @@ static struct dentry* d_find_primary(struct inode *inode)
42904294
*/
42914295
static int reconnect_caps_cb(struct inode *inode, int mds, void *arg)
42924296
{
4297+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
42934298
union {
42944299
struct ceph_mds_cap_reconnect v2;
42954300
struct ceph_mds_cap_reconnect_v1 v1;
@@ -4307,7 +4312,7 @@ static int reconnect_caps_cb(struct inode *inode, int mds, void *arg)
43074312
dentry = d_find_primary(inode);
43084313
if (dentry) {
43094314
/* set pathbase to parent dir when msg_version >= 2 */
4310-
path = ceph_mdsc_build_path(dentry, &pathlen, &pathbase,
4315+
path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, &pathbase,
43114316
recon_state->msg_version >= 2);
43124317
dput(dentry);
43134318
if (IS_ERR(path)) {
@@ -5662,7 +5667,7 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
56625667
return;
56635668
}
56645669

5665-
newmap = ceph_mdsmap_decode(&p, end, ceph_msgr2(mdsc->fsc->client));
5670+
newmap = ceph_mdsmap_decode(mdsc, &p, end, ceph_msgr2(mdsc->fsc->client));
56665671
if (IS_ERR(newmap)) {
56675672
err = PTR_ERR(newmap);
56685673
goto bad_unlock;

fs/ceph/mds_client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ static inline void ceph_mdsc_free_path(char *path, int len)
581581
__putname(path - (PATH_MAX - 1 - len));
582582
}
583583

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,
585586
int for_wire);
586587

587588
extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);

fs/ceph/mdsmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ static int __decode_and_drop_compat_set(void **p, void* end)
114114
* Ignore any fields we don't care about (there are quite a few of
115115
* them).
116116
*/
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)
118119
{
119120
struct ceph_mdsmap *m;
120121
const void *start = *p;

fs/ceph/snap.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ static int cmpu64_rev(const void *a, const void *b)
329329
/*
330330
* build the snap context for a given realm.
331331
*/
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,
333334
struct list_head *realm_queue,
334335
struct list_head *dirty_realms)
335336
{
@@ -425,7 +426,8 @@ static int build_snap_context(struct ceph_snap_realm *realm,
425426
/*
426427
* rebuild snap context for the given realm and all of its children.
427428
*/
428-
static void rebuild_snap_realms(struct ceph_snap_realm *realm,
429+
static void rebuild_snap_realms(struct ceph_mds_client *mdsc,
430+
struct ceph_snap_realm *realm,
429431
struct list_head *dirty_realms)
430432
{
431433
LIST_HEAD(realm_queue);
@@ -451,7 +453,8 @@ static void rebuild_snap_realms(struct ceph_snap_realm *realm,
451453
continue;
452454
}
453455

454-
last = build_snap_context(_realm, &realm_queue, dirty_realms);
456+
last = build_snap_context(mdsc, _realm, &realm_queue,
457+
dirty_realms);
455458
dout("%s %llx %p, %s\n", __func__, _realm->ino, _realm,
456459
last > 0 ? "is deferred" : !last ? "succeeded" : "failed");
457460

@@ -708,7 +711,8 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
708711
* Queue cap_snaps for snap writeback for this realm and its children.
709712
* Called under snap_rwsem, so realm topology won't change.
710713
*/
711-
static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)
714+
static void queue_realm_cap_snaps(struct ceph_mds_client *mdsc,
715+
struct ceph_snap_realm *realm)
712716
{
713717
struct ceph_inode_info *ci;
714718
struct inode *lastinode = NULL;
@@ -855,7 +859,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
855859

856860
/* rebuild_snapcs when we reach the _end_ (root) of the trace */
857861
if (realm_to_rebuild && p >= e)
858-
rebuild_snap_realms(realm_to_rebuild, &dirty_realms);
862+
rebuild_snap_realms(mdsc, realm_to_rebuild, &dirty_realms);
859863

860864
if (!first_realm)
861865
first_realm = realm;
@@ -873,7 +877,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
873877
realm = list_first_entry(&dirty_realms, struct ceph_snap_realm,
874878
dirty_item);
875879
list_del_init(&realm->dirty_item);
876-
queue_realm_cap_snaps(realm);
880+
queue_realm_cap_snaps(mdsc, realm);
877881
}
878882

879883
if (realm_ret)

fs/ceph/super.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,8 @@ extern void ceph_add_cap(struct inode *inode,
12231223
unsigned cap, unsigned seq, u64 realmino, int flags,
12241224
struct ceph_cap **new_cap);
12251225
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);
12271228
extern void __ceph_remove_caps(struct ceph_inode_info *ci);
12281229
extern void ceph_put_cap(struct ceph_mds_client *mdsc,
12291230
struct ceph_cap *cap);

include/linux/ceph/mdsmap.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <linux/bug.h>
66
#include <linux/ceph/types.h>
77

8+
struct ceph_mds_client;
9+
810
/*
911
* mds map - describe servers in the mds cluster.
1012
*
@@ -65,7 +67,8 @@ static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
6567
}
6668

6769
extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
68-
struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2);
70+
struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
71+
void *end, bool msgr2);
6972
extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
7073
extern bool ceph_mdsmap_is_cluster_available(struct ceph_mdsmap *m);
7174

0 commit comments

Comments
 (0)