Re: [PATCH v3 01/15] libceph: introduce ceph_extract_encoded_string_kvmalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 08/19/2019 03:26 PM, Ilya Dryomov wrote:
On Mon, Jul 29, 2019 at 11:43 AM Dongsheng Yang
<dongsheng.yang@xxxxxxxxxxxx>  wrote:
When we are going to extract the encoded string, there
would be a large string encoded.

Especially in the journaling case, if we use the default
journal object size, 16M, there could be a 16M string
encoded in this object.

Signed-off-by: Dongsheng Yang<dongsheng.yang@xxxxxxxxxxxx>
---
  include/linux/ceph/decode.h | 21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
index 450384f..555879f 100644
--- a/include/linux/ceph/decode.h
+++ b/include/linux/ceph/decode.h
@@ -104,8 +104,11 @@ static inline bool ceph_has_room(void **p, void *end, size_t n)
   *     beyond the "end" pointer provided (-ERANGE)
   *   - memory could not be allocated for the result (-ENOMEM)
   */
-static inline char *ceph_extract_encoded_string(void **p, void *end,
-                                               size_t *lenp, gfp_t gfp)
+typedef void * (mem_alloc_t)(size_t size, gfp_t flags);
+extern void *ceph_kvmalloc(size_t size, gfp_t flags);
+static inline char *extract_encoded_string(void **p, void *end,
+                                          mem_alloc_t alloc_fn,
+                                          size_t *lenp, gfp_t gfp)
  {
         u32 len;
         void *sp = *p;
@@ -115,7 +118,7 @@ static inline char *ceph_extract_encoded_string(void **p, void *end,
         if (!ceph_has_room(&sp, end, len))
                 goto bad;

-       buf = kmalloc(len + 1, gfp);
+       buf = alloc_fn(len + 1, gfp);
         if (!buf)
                 return ERR_PTR(-ENOMEM);

@@ -133,6 +136,18 @@ static inline char *ceph_extract_encoded_string(void **p, void *end,
         return ERR_PTR(-ERANGE);
  }

+static inline char *ceph_extract_encoded_string(void **p, void *end,
+                                               size_t *lenp, gfp_t gfp)
+{
+       return extract_encoded_string(p, end, kmalloc, lenp, gfp);
+}
+
+static inline char *ceph_extract_encoded_string_kvmalloc(void **p, void *end,
+                                                        size_t *lenp, gfp_t gfp)
+{
+       return extract_encoded_string(p, end, ceph_kvmalloc, lenp, gfp);
+}
+
  /*
   * skip helpers
   */
This is only for replaying, right?

This is for journal fetching, which is a part for replaying. But if we don't do replay, we still need to do journal fetching and journal preprocess to know whether there is
uncommitted journal.

Thanx
Thanks,

                 Ilya






[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux