ceph: keep i_snap_realm while there are writers
when reconnecting to MDS is denied, we remove session caps forcibly. But it's possible there are ongoing write, the write code needs to reference i_snap_realm. So if there are ongoing write, we keep i_snap_realm. Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
Родитель
3ef650d398
Коммит
db40cc1702
|
@ -896,6 +896,18 @@ int ceph_is_any_caps(struct inode *inode)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drop_inode_snap_realm(struct ceph_inode_info *ci)
|
||||||
|
{
|
||||||
|
struct ceph_snap_realm *realm = ci->i_snap_realm;
|
||||||
|
spin_lock(&realm->inodes_with_caps_lock);
|
||||||
|
list_del_init(&ci->i_snap_realm_item);
|
||||||
|
ci->i_snap_realm_counter++;
|
||||||
|
ci->i_snap_realm = NULL;
|
||||||
|
spin_unlock(&realm->inodes_with_caps_lock);
|
||||||
|
ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc,
|
||||||
|
realm);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove a cap. Take steps to deal with a racing iterate_session_caps.
|
* Remove a cap. Take steps to deal with a racing iterate_session_caps.
|
||||||
*
|
*
|
||||||
|
@ -946,15 +958,13 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
|
||||||
if (removed)
|
if (removed)
|
||||||
ceph_put_cap(mdsc, cap);
|
ceph_put_cap(mdsc, cap);
|
||||||
|
|
||||||
if (!__ceph_is_any_caps(ci) && ci->i_snap_realm) {
|
/* when reconnect denied, we remove session caps forcibly,
|
||||||
struct ceph_snap_realm *realm = ci->i_snap_realm;
|
* i_wr_ref can be non-zero. If there are ongoing write,
|
||||||
spin_lock(&realm->inodes_with_caps_lock);
|
* keep i_snap_realm.
|
||||||
list_del_init(&ci->i_snap_realm_item);
|
*/
|
||||||
ci->i_snap_realm_counter++;
|
if (!__ceph_is_any_caps(ci) && ci->i_wr_ref == 0 && ci->i_snap_realm)
|
||||||
ci->i_snap_realm = NULL;
|
drop_inode_snap_realm(ci);
|
||||||
spin_unlock(&realm->inodes_with_caps_lock);
|
|
||||||
ceph_put_snap_realm(mdsc, realm);
|
|
||||||
}
|
|
||||||
if (!__ceph_is_any_real_caps(ci))
|
if (!__ceph_is_any_real_caps(ci))
|
||||||
__cap_delay_cancel(mdsc, ci);
|
__cap_delay_cancel(mdsc, ci);
|
||||||
}
|
}
|
||||||
|
@ -2309,6 +2319,9 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
|
||||||
wake = 1;
|
wake = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* see comment in __ceph_remove_cap() */
|
||||||
|
if (!__ceph_is_any_caps(ci) && ci->i_snap_realm)
|
||||||
|
drop_inode_snap_realm(ci);
|
||||||
}
|
}
|
||||||
spin_unlock(&ci->i_ceph_lock);
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче