Skip to content

Commit 2678da8

Browse files
lxbszidryomov
authored andcommitted
ceph: add ceph_sb_to_mdsc helper support to parse the mdsc
This will help simplify the code. [ jlayton: fix minor merge conflict in quota.c ] Signed-off-by: Xiubo Li <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent c5f575e commit 2678da8

File tree

8 files changed

+26
-30
lines changed

8 files changed

+26
-30
lines changed

fs/ceph/caps.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,9 +1906,8 @@ bool __ceph_should_report_size(struct ceph_inode_info *ci)
19061906
void ceph_check_caps(struct ceph_inode_info *ci, int flags,
19071907
struct ceph_mds_session *session)
19081908
{
1909-
struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode);
1910-
struct ceph_mds_client *mdsc = fsc->mdsc;
19111909
struct inode *inode = &ci->vfs_inode;
1910+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
19121911
struct ceph_cap *cap;
19131912
u64 flush_tid, oldest_flush_tid;
19141913
int file_wanted, used, cap_used;

fs/ceph/dir.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ static int __dir_lease_try_check(const struct dentry *dentry);
3838
static int ceph_d_init(struct dentry *dentry)
3939
{
4040
struct ceph_dentry_info *di;
41-
struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
42-
struct ceph_mds_client *mdsc = fsc->mdsc;
41+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb);
4342

4443
di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
4544
if (!di)
@@ -738,7 +737,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
738737
unsigned int flags)
739738
{
740739
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
741-
struct ceph_mds_client *mdsc = fsc->mdsc;
740+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
742741
struct ceph_mds_request *req;
743742
int op;
744743
int mask;
@@ -827,8 +826,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
827826
static int ceph_mknod(struct inode *dir, struct dentry *dentry,
828827
umode_t mode, dev_t rdev)
829828
{
830-
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
831-
struct ceph_mds_client *mdsc = fsc->mdsc;
829+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
832830
struct ceph_mds_request *req;
833831
struct ceph_acl_sec_ctx as_ctx = {};
834832
int err;
@@ -889,8 +887,7 @@ static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode,
889887
static int ceph_symlink(struct inode *dir, struct dentry *dentry,
890888
const char *dest)
891889
{
892-
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
893-
struct ceph_mds_client *mdsc = fsc->mdsc;
890+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
894891
struct ceph_mds_request *req;
895892
struct ceph_acl_sec_ctx as_ctx = {};
896893
int err;
@@ -942,8 +939,7 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
942939

943940
static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
944941
{
945-
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
946-
struct ceph_mds_client *mdsc = fsc->mdsc;
942+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
947943
struct ceph_mds_request *req;
948944
struct ceph_acl_sec_ctx as_ctx = {};
949945
int err = -EROFS;
@@ -1010,8 +1006,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
10101006
static int ceph_link(struct dentry *old_dentry, struct inode *dir,
10111007
struct dentry *dentry)
10121008
{
1013-
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
1014-
struct ceph_mds_client *mdsc = fsc->mdsc;
1009+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
10151010
struct ceph_mds_request *req;
10161011
int err;
10171012

@@ -1192,8 +1187,7 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
11921187
struct inode *new_dir, struct dentry *new_dentry,
11931188
unsigned int flags)
11941189
{
1195-
struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
1196-
struct ceph_mds_client *mdsc = fsc->mdsc;
1190+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(old_dir->i_sb);
11971191
struct ceph_mds_request *req;
11981192
int op = CEPH_MDS_OP_RENAME;
11991193
int err;

fs/ceph/file.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty)
182182
static struct ceph_mds_request *
183183
prepare_open_request(struct super_block *sb, int flags, int create_mode)
184184
{
185-
struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
186-
struct ceph_mds_client *mdsc = fsc->mdsc;
185+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb);
187186
struct ceph_mds_request *req;
188187
int want_auth = USE_ANY_MDS;
189188
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)
283282
*/
284283
int ceph_renew_caps(struct inode *inode, int fmode)
285284
{
286-
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
285+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
287286
struct ceph_inode_info *ci = ceph_inode(inode);
288287
struct ceph_mds_request *req;
289288
int err, flags, wanted;
@@ -1027,8 +1026,7 @@ static void ceph_aio_complete_req(struct ceph_osd_request *req)
10271026
struct inode *inode = req->r_inode;
10281027
struct ceph_aio_request *aio_req = req->r_priv;
10291028
struct ceph_osd_data *osd_data = osd_req_op_extent_osd_data(req, 0);
1030-
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
1031-
struct ceph_client_metric *metric = &fsc->mdsc->metric;
1029+
struct ceph_client_metric *metric = &ceph_sb_to_mdsc(inode->i_sb)->metric;
10321030

10331031
BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_BVECS);
10341032
BUG_ON(!osd_data->num_bvecs);

fs/ceph/inode.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,7 @@ void ceph_evict_inode(struct inode *inode)
558558
* caps in i_snap_caps.
559559
*/
560560
if (ci->i_snap_realm) {
561-
struct ceph_mds_client *mdsc =
562-
ceph_inode_to_client(inode)->mdsc;
561+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
563562
if (ceph_snap(inode) == CEPH_NOSNAP) {
564563
struct ceph_snap_realm *realm = ci->i_snap_realm;
565564
dout(" dropping residual ref to snap realm %p\n",
@@ -739,7 +738,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
739738
struct ceph_mds_session *session, int cap_fmode,
740739
struct ceph_cap_reservation *caps_reservation)
741740
{
742-
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
741+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
743742
struct ceph_mds_reply_inode *info = iinfo->in;
744743
struct ceph_inode_info *ci = ceph_inode(inode);
745744
int issued, new_issued, info_caps;

fs/ceph/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const struct file_lock_operations ceph_fl_lock_ops = {
6363
static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode,
6464
int cmd, u8 wait, struct file_lock *fl)
6565
{
66-
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
66+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
6767
struct ceph_mds_request *req;
6868
int err;
6969
u64 length = 0;

fs/ceph/quota.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
void ceph_adjust_quota_realms_count(struct inode *inode, bool inc)
1414
{
15-
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
15+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
1616
if (inc)
1717
atomic64_inc(&mdsc->quotarealms_count);
1818
else
@@ -21,8 +21,8 @@ void ceph_adjust_quota_realms_count(struct inode *inode, bool inc)
2121

2222
static inline bool ceph_has_realms_with_quotas(struct inode *inode)
2323
{
24-
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
25-
struct super_block *sb = mdsc->fsc->sb;
24+
struct super_block *sb = inode->i_sb;
25+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb);
2626
struct inode *root = d_inode(sb->s_root);
2727

2828
if (atomic64_read(&mdsc->quotarealms_count) > 0)
@@ -266,7 +266,7 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
266266

267267
static bool ceph_quota_is_same_realm(struct inode *old, struct inode *new)
268268
{
269-
struct ceph_mds_client *mdsc = ceph_inode_to_client(old)->mdsc;
269+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(old->i_sb);
270270
struct ceph_snap_realm *old_realm, *new_realm;
271271
bool is_same;
272272

@@ -313,7 +313,7 @@ enum quota_check_op {
313313
static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
314314
loff_t delta)
315315
{
316-
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
316+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
317317
struct ceph_inode_info *ci;
318318
struct ceph_snap_realm *realm, *next;
319319
struct inode *in;

fs/ceph/snap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
602602
struct ceph_cap_snap *capsnap)
603603
{
604604
struct inode *inode = &ci->vfs_inode;
605-
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
605+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
606606

607607
BUG_ON(capsnap->writing);
608608
capsnap->size = inode->i_size;

fs/ceph/super.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,12 @@ ceph_sb_to_client(const struct super_block *sb)
451451
return (struct ceph_fs_client *)sb->s_fs_info;
452452
}
453453

454+
static inline struct ceph_mds_client *
455+
ceph_sb_to_mdsc(const struct super_block *sb)
456+
{
457+
return (struct ceph_mds_client *)ceph_sb_to_client(sb)->mdsc;
458+
}
459+
454460
static inline struct ceph_vino
455461
ceph_vino(const struct inode *inode)
456462
{

0 commit comments

Comments
 (0)