diff mbox series

ceph: rework ceph_alloc_sparse_ext_map

Message ID 20220401143028.22039-1-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show
Series ceph: rework ceph_alloc_sparse_ext_map | expand

Commit Message

Jeffrey Layton April 1, 2022, 2:30 p.m. UTC
Make it a wrapper around a version that requires a length and just have
it default to CEPH_SPARSE_EXT_ARRAY_INITIAL.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/addr.c                  |  3 +--
 fs/ceph/file.c                  |  8 ++++----
 fs/ceph/super.h                 |  7 -------
 include/linux/ceph/osd_client.h | 14 +++++++++++++-
 net/ceph/osd_client.c           |  4 ++--
 5 files changed, 20 insertions(+), 16 deletions(-)

Another one for the sparse_read series. Again, I'll probably fold this
into the appropriate patches and re-push into testing.
diff mbox series

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index cc4f561bd03c..b85eb4963e57 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -346,8 +346,7 @@  static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
 	}
 
 	if (sparse) {
-		err = ceph_alloc_sparse_ext_map(&req->r_ops[0],
-					CEPH_SPARSE_EXT_ARRAY_INITIAL);
+		err = ceph_alloc_sparse_ext_map(&req->r_ops[0]);
 		if (err) {
 			ceph_osdc_put_request(req);
 			goto out;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 5072570c2203..64580a2edc1b 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1009,7 +1009,7 @@  ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
 
 		op = &req->r_ops[0];
 		if (sparse) {
-			ret = ceph_alloc_sparse_ext_map(op, CEPH_SPARSE_EXT_ARRAY_INITIAL);
+			ret = ceph_alloc_sparse_ext_map(op);
 			if (ret) {
 				ceph_osdc_put_request(req);
 				break;
@@ -1462,7 +1462,7 @@  ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
 		osd_req_op_extent_osd_data_bvecs(req, 0, bvecs, num_pages, len);
 		op = &req->r_ops[0];
 		if (sparse) {
-			ret = ceph_alloc_sparse_ext_map(op, CEPH_SPARSE_EXT_ARRAY_INITIAL);
+			ret = ceph_alloc_sparse_ext_map(op);
 			if (ret) {
 				ceph_osdc_put_request(req);
 				break;
@@ -1708,7 +1708,7 @@  ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
 							 offset_in_page(first_pos),
 							 false, false);
 				/* We only expect a single extent here */
-				ret = ceph_alloc_sparse_ext_map(op, 1);
+				ret = __ceph_alloc_sparse_ext_map(op, 1);
 				if (ret) {
 					ceph_osdc_put_request(req);
 					ceph_release_page_vector(pages, num_pages);
@@ -1727,7 +1727,7 @@  ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
 							ci->i_truncate_seq);
 				}
 
-				ret = ceph_alloc_sparse_ext_map(op, 1);
+				ret = __ceph_alloc_sparse_ext_map(op, 1);
 				if (ret) {
 					ceph_osdc_put_request(req);
 					ceph_release_page_vector(pages, num_pages);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index d626d228bacc..e847afb8448f 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -81,13 +81,6 @@ 
 #define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT      5  /* cap release delay */
 #define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT     60  /* cap release delay */
 
-/*
- * How big an extent array should we preallocate for a sparse read? This is
- * just a starting value.  If we get more than this back from the OSD, the
- * receiver will reallocate.
- */
-#define CEPH_SPARSE_EXT_ARRAY_INITIAL	16
-
 struct ceph_mount_options {
 	unsigned int flags;
 
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index df092b678d58..8c7f34df66d3 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -556,7 +556,19 @@  extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
 				      u32 truncate_seq, u64 truncate_size,
 				      bool use_mempool);
 
-int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt);
+int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt);
+
+/*
+ * How big an extent array should we preallocate for a sparse read? This is
+ * just a starting value.  If we get more than this back from the OSD, the
+ * receiver will reallocate.
+ */
+#define CEPH_SPARSE_EXT_ARRAY_INITIAL  16
+
+static inline int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op)
+{
+	return __ceph_alloc_sparse_ext_map(op, CEPH_SPARSE_EXT_ARRAY_INITIAL);
+}
 
 extern void ceph_osdc_get_request(struct ceph_osd_request *req);
 extern void ceph_osdc_put_request(struct ceph_osd_request *req);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 5cb7635bb457..39d38b69a953 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1165,7 +1165,7 @@  struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
 }
 EXPORT_SYMBOL(ceph_osdc_new_request);
 
-int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
+int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
 {
 	op->extent.sparse_ext_cnt = cnt;
 	op->extent.sparse_ext = kmalloc_array(cnt,
@@ -1175,7 +1175,7 @@  int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
 		return -ENOMEM;
 	return 0;
 }
-EXPORT_SYMBOL(ceph_alloc_sparse_ext_map);
+EXPORT_SYMBOL(__ceph_alloc_sparse_ext_map);
 
 /*
  * We keep osd requests in an rbtree, sorted by ->r_tid.