Skip to content

Commit 95cca2b

Browse files
ukernelidryomov
authored andcommitted
ceph: limit osd write size
OSD has a configurable limitation of max write size. OSD return error if write request size is larger than the limitation. For now, set max write size to CEPH_MSG_MAX_DATA_LEN. It should be small enough. Signed-off-by: "Yan, Zheng" <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent aa18792 commit 95cca2b

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

fs/ceph/addr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,8 @@ static int ceph_writepages_start(struct address_space *mapping,
779779
mapping_set_error(mapping, -EIO);
780780
return -EIO; /* we're in a forced umount, don't write! */
781781
}
782-
if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize)
782+
if (fsc->mount_options->wsize < wsize)
783783
wsize = fsc->mount_options->wsize;
784-
if (wsize < PAGE_SIZE)
785-
wsize = PAGE_SIZE;
786784
max_pages_ever = wsize >> PAGE_SHIFT;
787785

788786
pagevec_init(&pvec, 0);

fs/ceph/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,9 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
887887
break;
888888
}
889889

890-
if (!write)
890+
if (write)
891+
size = min_t(u64, size, fsc->mount_options->wsize);
892+
else
891893
size = min_t(u64, size, fsc->mount_options->rsize);
892894

893895
len = size;

fs/ceph/super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ static int parse_fsopt_token(char *c, void *private)
233233
break;
234234
/* misc */
235235
case Opt_wsize:
236-
fsopt->wsize = intval;
236+
if (intval < PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
237+
return -EINVAL;
238+
fsopt->wsize = ALIGN(intval, PAGE_SIZE);
237239
break;
238240
case Opt_rsize:
239241
if (intval < PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
@@ -392,6 +394,7 @@ static int parse_mount_options(struct ceph_mount_options **pfsopt,
392394
fsopt->sb_flags = flags;
393395
fsopt->flags = CEPH_MOUNT_OPT_DEFAULT;
394396

397+
fsopt->wsize = CEPH_MAX_WRITE_SIZE;
395398
fsopt->rsize = CEPH_MAX_READ_SIZE;
396399
fsopt->rasize = CEPH_RASIZE_DEFAULT;
397400
fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);

fs/ceph/super.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848

4949
/* max size of osd read request, limited by libceph */
5050
#define CEPH_MAX_READ_SIZE CEPH_MSG_MAX_DATA_LEN
51+
/* osd has a configurable limitaion of max write size.
52+
* CEPH_MSG_MAX_DATA_LEN should be small enough. */
53+
#define CEPH_MAX_WRITE_SIZE CEPH_MSG_MAX_DATA_LEN
5154
#define CEPH_RASIZE_DEFAULT (8192*1024) /* max readahead */
5255
#define CEPH_MAX_READDIR_DEFAULT 1024
5356
#define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024)

0 commit comments

Comments
 (0)