Skip to content

Commit 18d44c5

Browse files
committed
ceph: allocate sparse_ext map only for sparse reads
If mounted with sparseread option, ceph_direct_read_write() ends up making an unnecessarily allocation for O_DIRECT writes. Fixes: 03bc06c ("ceph: add new mount option to enable sparse reads") Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Alex Markuze <amarkuze@redhat.com>
1 parent 66e0c4f commit 18d44c5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fs/ceph/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
15521552
}
15531553

15541554
op = &req->r_ops[0];
1555-
if (sparse) {
1555+
if (!write && sparse) {
15561556
extent_cnt = __ceph_sparse_read_ext_count(inode, size);
15571557
ret = ceph_alloc_sparse_ext_map(op, extent_cnt);
15581558
if (ret) {

net/ceph/osd_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ EXPORT_SYMBOL(ceph_osdc_new_request);
11731173

11741174
int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
11751175
{
1176+
WARN_ON(op->op != CEPH_OSD_OP_SPARSE_READ);
1177+
11761178
op->extent.sparse_ext_cnt = cnt;
11771179
op->extent.sparse_ext = kmalloc_array(cnt,
11781180
sizeof(*op->extent.sparse_ext),

0 commit comments

Comments
 (0)