diff options
author | Yan, Zheng <zyan@redhat.com> | 2015-05-05 09:22:13 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2015-06-25 04:49:29 -0400 |
commit | affbc19a68f9966ad65a773db405f78e2bafc07b (patch) | |
tree | 63c34c40700e8b1fe1a73f1df244f3143b7aa99f /fs/ceph/caps.c | |
parent | 622f3e250f498976ad4cbae6f2be5cb359ded4f5 (diff) |
ceph: make sure syncfs flushes all cap snaps
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r-- | fs/ceph/caps.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 900c05fd77d8..bbd969e16a01 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -1259,14 +1259,14 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, | |||
1259 | * asynchronously back to the MDS once sync writes complete and dirty | 1259 | * asynchronously back to the MDS once sync writes complete and dirty |
1260 | * data is written out. | 1260 | * data is written out. |
1261 | * | 1261 | * |
1262 | * Unless @again is true, skip cap_snaps that were already sent to | 1262 | * Unless @kick is true, skip cap_snaps that were already sent to |
1263 | * the MDS (i.e., during this session). | 1263 | * the MDS (i.e., during this session). |
1264 | * | 1264 | * |
1265 | * Called under i_ceph_lock. Takes s_mutex as needed. | 1265 | * Called under i_ceph_lock. Takes s_mutex as needed. |
1266 | */ | 1266 | */ |
1267 | void __ceph_flush_snaps(struct ceph_inode_info *ci, | 1267 | void __ceph_flush_snaps(struct ceph_inode_info *ci, |
1268 | struct ceph_mds_session **psession, | 1268 | struct ceph_mds_session **psession, |
1269 | int again) | 1269 | int kick) |
1270 | __releases(ci->i_ceph_lock) | 1270 | __releases(ci->i_ceph_lock) |
1271 | __acquires(ci->i_ceph_lock) | 1271 | __acquires(ci->i_ceph_lock) |
1272 | { | 1272 | { |
@@ -1307,7 +1307,7 @@ retry: | |||
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | /* only flush each capsnap once */ | 1309 | /* only flush each capsnap once */ |
1310 | if (!again && !list_empty(&capsnap->flushing_item)) { | 1310 | if (!kick && !list_empty(&capsnap->flushing_item)) { |
1311 | dout("already flushed %p, skipping\n", capsnap); | 1311 | dout("already flushed %p, skipping\n", capsnap); |
1312 | continue; | 1312 | continue; |
1313 | } | 1313 | } |
@@ -1317,6 +1317,9 @@ retry: | |||
1317 | 1317 | ||
1318 | if (session && session->s_mds != mds) { | 1318 | if (session && session->s_mds != mds) { |
1319 | dout("oops, wrong session %p mutex\n", session); | 1319 | dout("oops, wrong session %p mutex\n", session); |
1320 | if (kick) | ||
1321 | goto out; | ||
1322 | |||
1320 | mutex_unlock(&session->s_mutex); | 1323 | mutex_unlock(&session->s_mutex); |
1321 | ceph_put_mds_session(session); | 1324 | ceph_put_mds_session(session); |
1322 | session = NULL; | 1325 | session = NULL; |
@@ -1342,10 +1345,9 @@ retry: | |||
1342 | 1345 | ||
1343 | capsnap->flush_tid = ++ci->i_cap_flush_last_tid; | 1346 | capsnap->flush_tid = ++ci->i_cap_flush_last_tid; |
1344 | atomic_inc(&capsnap->nref); | 1347 | atomic_inc(&capsnap->nref); |
1345 | if (!list_empty(&capsnap->flushing_item)) | 1348 | if (list_empty(&capsnap->flushing_item)) |
1346 | list_del_init(&capsnap->flushing_item); | 1349 | list_add_tail(&capsnap->flushing_item, |
1347 | list_add_tail(&capsnap->flushing_item, | 1350 | &session->s_cap_snaps_flushing); |
1348 | &session->s_cap_snaps_flushing); | ||
1349 | spin_unlock(&ci->i_ceph_lock); | 1351 | spin_unlock(&ci->i_ceph_lock); |
1350 | 1352 | ||
1351 | dout("flush_snaps %p cap_snap %p follows %lld tid %llu\n", | 1353 | dout("flush_snaps %p cap_snap %p follows %lld tid %llu\n", |
@@ -2876,6 +2878,7 @@ static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid, | |||
2876 | struct ceph_mds_session *session) | 2878 | struct ceph_mds_session *session) |
2877 | { | 2879 | { |
2878 | struct ceph_inode_info *ci = ceph_inode(inode); | 2880 | struct ceph_inode_info *ci = ceph_inode(inode); |
2881 | struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; | ||
2879 | u64 follows = le64_to_cpu(m->snap_follows); | 2882 | u64 follows = le64_to_cpu(m->snap_follows); |
2880 | struct ceph_cap_snap *capsnap; | 2883 | struct ceph_cap_snap *capsnap; |
2881 | int drop = 0; | 2884 | int drop = 0; |
@@ -2899,6 +2902,7 @@ static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid, | |||
2899 | list_del(&capsnap->ci_item); | 2902 | list_del(&capsnap->ci_item); |
2900 | list_del(&capsnap->flushing_item); | 2903 | list_del(&capsnap->flushing_item); |
2901 | ceph_put_cap_snap(capsnap); | 2904 | ceph_put_cap_snap(capsnap); |
2905 | wake_up_all(&mdsc->cap_flushing_wq); | ||
2902 | drop = 1; | 2906 | drop = 1; |
2903 | break; | 2907 | break; |
2904 | } else { | 2908 | } else { |