diff options
author | Yan, Zheng <zyan@redhat.com> | 2015-06-10 05:26:13 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2015-06-25 04:49:31 -0400 |
commit | f66fd9f0952187d274c13c136b74548f792c1925 (patch) | |
tree | c021f04f69b116f2673fdfb2354a99871f8f03a4 /fs/ceph/file.c | |
parent | e548e9b93d3e565e42b938a99804114565be1f81 (diff) |
ceph: pre-allocate data structure that tracks caps flushing
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r-- | fs/ceph/file.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 0a76a370d798..8a4eb4d21d3c 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -939,6 +939,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
939 | struct ceph_inode_info *ci = ceph_inode(inode); | 939 | struct ceph_inode_info *ci = ceph_inode(inode); |
940 | struct ceph_osd_client *osdc = | 940 | struct ceph_osd_client *osdc = |
941 | &ceph_sb_to_client(inode->i_sb)->client->osdc; | 941 | &ceph_sb_to_client(inode->i_sb)->client->osdc; |
942 | struct ceph_cap_flush *prealloc_cf; | ||
942 | ssize_t count, written = 0; | 943 | ssize_t count, written = 0; |
943 | int err, want, got; | 944 | int err, want, got; |
944 | loff_t pos; | 945 | loff_t pos; |
@@ -946,6 +947,10 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
946 | if (ceph_snap(inode) != CEPH_NOSNAP) | 947 | if (ceph_snap(inode) != CEPH_NOSNAP) |
947 | return -EROFS; | 948 | return -EROFS; |
948 | 949 | ||
950 | prealloc_cf = ceph_alloc_cap_flush(); | ||
951 | if (!prealloc_cf) | ||
952 | return -ENOMEM; | ||
953 | |||
949 | mutex_lock(&inode->i_mutex); | 954 | mutex_lock(&inode->i_mutex); |
950 | 955 | ||
951 | /* We can write back this queue in page reclaim */ | 956 | /* We can write back this queue in page reclaim */ |
@@ -1050,7 +1055,8 @@ retry_snap: | |||
1050 | int dirty; | 1055 | int dirty; |
1051 | spin_lock(&ci->i_ceph_lock); | 1056 | spin_lock(&ci->i_ceph_lock); |
1052 | ci->i_inline_version = CEPH_INLINE_NONE; | 1057 | ci->i_inline_version = CEPH_INLINE_NONE; |
1053 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); | 1058 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR, |
1059 | &prealloc_cf); | ||
1054 | spin_unlock(&ci->i_ceph_lock); | 1060 | spin_unlock(&ci->i_ceph_lock); |
1055 | if (dirty) | 1061 | if (dirty) |
1056 | __mark_inode_dirty(inode, dirty); | 1062 | __mark_inode_dirty(inode, dirty); |
@@ -1074,6 +1080,7 @@ retry_snap: | |||
1074 | out: | 1080 | out: |
1075 | mutex_unlock(&inode->i_mutex); | 1081 | mutex_unlock(&inode->i_mutex); |
1076 | out_unlocked: | 1082 | out_unlocked: |
1083 | ceph_free_cap_flush(prealloc_cf); | ||
1077 | current->backing_dev_info = NULL; | 1084 | current->backing_dev_info = NULL; |
1078 | return written ? written : err; | 1085 | return written ? written : err; |
1079 | } | 1086 | } |
@@ -1270,6 +1277,7 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1270 | struct ceph_inode_info *ci = ceph_inode(inode); | 1277 | struct ceph_inode_info *ci = ceph_inode(inode); |
1271 | struct ceph_osd_client *osdc = | 1278 | struct ceph_osd_client *osdc = |
1272 | &ceph_inode_to_client(inode)->client->osdc; | 1279 | &ceph_inode_to_client(inode)->client->osdc; |
1280 | struct ceph_cap_flush *prealloc_cf; | ||
1273 | int want, got = 0; | 1281 | int want, got = 0; |
1274 | int dirty; | 1282 | int dirty; |
1275 | int ret = 0; | 1283 | int ret = 0; |
@@ -1282,6 +1290,10 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1282 | if (!S_ISREG(inode->i_mode)) | 1290 | if (!S_ISREG(inode->i_mode)) |
1283 | return -EOPNOTSUPP; | 1291 | return -EOPNOTSUPP; |
1284 | 1292 | ||
1293 | prealloc_cf = ceph_alloc_cap_flush(); | ||
1294 | if (!prealloc_cf) | ||
1295 | return -ENOMEM; | ||
1296 | |||
1285 | mutex_lock(&inode->i_mutex); | 1297 | mutex_lock(&inode->i_mutex); |
1286 | 1298 | ||
1287 | if (ceph_snap(inode) != CEPH_NOSNAP) { | 1299 | if (ceph_snap(inode) != CEPH_NOSNAP) { |
@@ -1328,7 +1340,8 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1328 | if (!ret) { | 1340 | if (!ret) { |
1329 | spin_lock(&ci->i_ceph_lock); | 1341 | spin_lock(&ci->i_ceph_lock); |
1330 | ci->i_inline_version = CEPH_INLINE_NONE; | 1342 | ci->i_inline_version = CEPH_INLINE_NONE; |
1331 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); | 1343 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR, |
1344 | &prealloc_cf); | ||
1332 | spin_unlock(&ci->i_ceph_lock); | 1345 | spin_unlock(&ci->i_ceph_lock); |
1333 | if (dirty) | 1346 | if (dirty) |
1334 | __mark_inode_dirty(inode, dirty); | 1347 | __mark_inode_dirty(inode, dirty); |
@@ -1337,6 +1350,7 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1337 | ceph_put_cap_refs(ci, got); | 1350 | ceph_put_cap_refs(ci, got); |
1338 | unlock: | 1351 | unlock: |
1339 | mutex_unlock(&inode->i_mutex); | 1352 | mutex_unlock(&inode->i_mutex); |
1353 | ceph_free_cap_flush(prealloc_cf); | ||
1340 | return ret; | 1354 | return ret; |
1341 | } | 1355 | } |
1342 | 1356 | ||