Skip to content

Commit a76d0a9

Browse files
lxbszidryomov
authored andcommitted
ceph: don't WARN if we're forcibly removing the session caps
For example in the case of a forced umount, we'll remove all the session caps even if they are dirty. Move the warning to a wrapper function and make most of the callers use it. Call the core function when removing caps due to a forced umount. Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 42ad631 commit a76d0a9

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

fs/ceph/caps.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,17 +1114,16 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
11141114
return;
11151115
}
11161116

1117+
lockdep_assert_held(&ci->i_ceph_lock);
1118+
11171119
dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode);
11181120

11191121
mdsc = ceph_inode_to_client(&ci->vfs_inode)->mdsc;
11201122

11211123
/* remove from inode's cap rbtree, and clear auth cap */
11221124
rb_erase(&cap->ci_node, &ci->i_caps);
1123-
if (ci->i_auth_cap == cap) {
1124-
WARN_ON_ONCE(!list_empty(&ci->i_dirty_item) &&
1125-
!mdsc->fsc->blocklisted);
1125+
if (ci->i_auth_cap == cap)
11261126
ci->i_auth_cap = NULL;
1127-
}
11281127

11291128
/* remove from session list */
11301129
spin_lock(&session->s_cap_lock);
@@ -1176,6 +1175,28 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
11761175
}
11771176
}
11781177

1178+
void ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
1179+
{
1180+
struct ceph_inode_info *ci = cap->ci;
1181+
struct ceph_fs_client *fsc;
1182+
1183+
/* 'ci' being NULL means the remove have already occurred */
1184+
if (!ci) {
1185+
dout("%s: cap inode is NULL\n", __func__);
1186+
return;
1187+
}
1188+
1189+
lockdep_assert_held(&ci->i_ceph_lock);
1190+
1191+
fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
1192+
WARN_ON_ONCE(ci->i_auth_cap == cap &&
1193+
!list_empty(&ci->i_dirty_item) &&
1194+
!fsc->blocklisted &&
1195+
READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN);
1196+
1197+
__ceph_remove_cap(cap, queue_release);
1198+
}
1199+
11791200
struct cap_msg_args {
11801201
struct ceph_mds_session *session;
11811202
u64 ino, cid, follows;
@@ -1304,7 +1325,7 @@ void __ceph_remove_caps(struct ceph_inode_info *ci)
13041325
while (p) {
13051326
struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
13061327
p = rb_next(p);
1307-
__ceph_remove_cap(cap, true);
1328+
ceph_remove_cap(cap, true);
13081329
}
13091330
spin_unlock(&ci->i_ceph_lock);
13101331
}
@@ -3822,7 +3843,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
38223843
goto out_unlock;
38233844

38243845
if (target < 0) {
3825-
__ceph_remove_cap(cap, false);
3846+
ceph_remove_cap(cap, false);
38263847
goto out_unlock;
38273848
}
38283849

@@ -3857,7 +3878,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
38573878
change_auth_cap_ses(ci, tcap->session);
38583879
}
38593880
}
3860-
__ceph_remove_cap(cap, false);
3881+
ceph_remove_cap(cap, false);
38613882
goto out_unlock;
38623883
} else if (tsession) {
38633884
/* add placeholder for the export tagert */
@@ -3874,7 +3895,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
38743895
spin_unlock(&mdsc->cap_dirty_lock);
38753896
}
38763897

3877-
__ceph_remove_cap(cap, false);
3898+
ceph_remove_cap(cap, false);
38783899
goto out_unlock;
38793900
}
38803901

@@ -3985,7 +4006,7 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,
39854006
ocap->mseq, mds, le32_to_cpu(ph->seq),
39864007
le32_to_cpu(ph->mseq));
39874008
}
3988-
__ceph_remove_cap(ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE));
4009+
ceph_remove_cap(ocap, (ph->flags & CEPH_CAP_FLAG_RELEASE));
39894010
}
39904011

39914012
*old_issued = issued;

fs/ceph/mds_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
20162016

20172017
if (oissued) {
20182018
/* we aren't the only cap.. just remove us */
2019-
__ceph_remove_cap(cap, true);
2019+
ceph_remove_cap(cap, true);
20202020
(*remaining)--;
20212021
} else {
20222022
struct dentry *dentry;

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ extern void ceph_add_cap(struct inode *inode,
11381138
unsigned cap, unsigned seq, u64 realmino, int flags,
11391139
struct ceph_cap **new_cap);
11401140
extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release);
1141+
extern void ceph_remove_cap(struct ceph_cap *cap, bool queue_release);
11411142
extern void __ceph_remove_caps(struct ceph_inode_info *ci);
11421143
extern void ceph_put_cap(struct ceph_mds_client *mdsc,
11431144
struct ceph_cap *cap);

0 commit comments

Comments
 (0)