mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 02:34:01 +08:00
ceph: handle cap export race in try_flush_caps()
auth cap may change after releasing the i_ceph_lock Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
This commit is contained in:
parent
fc12c80aa5
commit
4fe59789ad
@ -1735,13 +1735,12 @@ ack:
|
|||||||
/*
|
/*
|
||||||
* Try to flush dirty caps back to the auth mds.
|
* Try to flush dirty caps back to the auth mds.
|
||||||
*/
|
*/
|
||||||
static int try_flush_caps(struct inode *inode, struct ceph_mds_session *session,
|
static int try_flush_caps(struct inode *inode, unsigned *flush_tid)
|
||||||
unsigned *flush_tid)
|
|
||||||
{
|
{
|
||||||
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
|
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
|
||||||
struct ceph_inode_info *ci = ceph_inode(inode);
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
||||||
int unlock_session = session ? 0 : 1;
|
|
||||||
int flushing = 0;
|
int flushing = 0;
|
||||||
|
struct ceph_mds_session *session = NULL;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
spin_lock(&ci->i_ceph_lock);
|
spin_lock(&ci->i_ceph_lock);
|
||||||
@ -1755,13 +1754,14 @@ retry:
|
|||||||
int want = __ceph_caps_wanted(ci);
|
int want = __ceph_caps_wanted(ci);
|
||||||
int delayed;
|
int delayed;
|
||||||
|
|
||||||
if (!session) {
|
if (!session || session != cap->session) {
|
||||||
spin_unlock(&ci->i_ceph_lock);
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
|
if (session)
|
||||||
|
mutex_unlock(&session->s_mutex);
|
||||||
session = cap->session;
|
session = cap->session;
|
||||||
mutex_lock(&session->s_mutex);
|
mutex_lock(&session->s_mutex);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
BUG_ON(session != cap->session);
|
|
||||||
if (cap->session->s_state < CEPH_MDS_SESSION_OPEN)
|
if (cap->session->s_state < CEPH_MDS_SESSION_OPEN)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1780,7 +1780,7 @@ retry:
|
|||||||
out:
|
out:
|
||||||
spin_unlock(&ci->i_ceph_lock);
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
out_unlocked:
|
out_unlocked:
|
||||||
if (session && unlock_session)
|
if (session)
|
||||||
mutex_unlock(&session->s_mutex);
|
mutex_unlock(&session->s_mutex);
|
||||||
return flushing;
|
return flushing;
|
||||||
}
|
}
|
||||||
@ -1865,7 +1865,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
|
|||||||
return ret;
|
return ret;
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
|
|
||||||
dirty = try_flush_caps(inode, NULL, &flush_tid);
|
dirty = try_flush_caps(inode, &flush_tid);
|
||||||
dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
|
dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1900,7 +1900,7 @@ int ceph_write_inode(struct inode *inode, struct writeback_control *wbc)
|
|||||||
|
|
||||||
dout("write_inode %p wait=%d\n", inode, wait);
|
dout("write_inode %p wait=%d\n", inode, wait);
|
||||||
if (wait) {
|
if (wait) {
|
||||||
dirty = try_flush_caps(inode, NULL, &flush_tid);
|
dirty = try_flush_caps(inode, &flush_tid);
|
||||||
if (dirty)
|
if (dirty)
|
||||||
err = wait_event_interruptible(ci->i_cap_wq,
|
err = wait_event_interruptible(ci->i_cap_wq,
|
||||||
caps_are_flushed(inode, flush_tid));
|
caps_are_flushed(inode, flush_tid));
|
||||||
|
Loading…
Reference in New Issue
Block a user