From patchwork Sat Jun 23 12:55:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10483619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D07FC604D3 for ; Sat, 23 Jun 2018 12:56:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D5D28D36 for ; Sat, 23 Jun 2018 12:56:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC5F028D4C; Sat, 23 Jun 2018 12:56:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61F3728D36 for ; Sat, 23 Jun 2018 12:56:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751917AbeFWM4K (ORCPT ); Sat, 23 Jun 2018 08:56:10 -0400 Received: from mout.gmx.net ([212.227.17.22]:49291 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbeFWM4I (ORCPT ); Sat, 23 Jun 2018 08:56:08 -0400 Received: from localhost.localdomain ([122.224.77.194]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MT74k-1fdpKe1an0-00S4HR; Sat, 23 Jun 2018 14:56:03 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 3/3] ceph: use ceph_pagelist_encode_string() for encoding string Date: Sat, 23 Jun 2018 20:55:24 +0800 Message-Id: <20180623125524.29233-3-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180623125524.29233-1-cgxu519@gmx.com> References: <20180623125524.29233-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:9EKpPc94YEvbtfx+C8aXZBahkTqx4rKgbiu1SgGj7z/jYDIdvvA jM1HUmwINrGUB2GCrBKSxv2FRKZERhdQbJzvUS+itYHvoAp5qzMlEbiSlvPHmDDBczle+hu 0YdUUNxUATWJW9nTocX9c41M7LjoI3gpt2oYe/58wdoBK8aLdoywtItT+SQfcKajs9AhOQu 7lPxtoqs2We+IhUEhfqvQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:PRjUwITyMoY=:yBb1dNKinPajKEEZuWwTrP FPpDXRBTtjt48hhogSlVn4AOPQekZZX8b+mqDmRAHdXaSff3g8ElhNlL5nlL4tVj2cefykb0P rzeLL7TfCArCAlwuxLxjjtPF8XPoID6xYxdDSBqc7wauE3semUGLQByE8lJY6XeA4gCpzgmAD fW2xgcwGIVWkEA3GXDREmeX/i2qkh94FpZJS1uruE/nSC4rHBC3DdnIupfmyCYgh3kucCEeYP rBE1SyHbbIVjFhIThI3myXhZZVAli/qO5w10GT8yxzrC224+wfVajSDAjd7gzMx+42rRUIsL9 BkmpmnvfguHddXtF4rHC8lXjERxIDM5igFYuTaOuQdBo2DnQYSgiG7fQ/my+7X2bf0zF2EhN8 coUqtQmf9HdboDYFg9CzFHXJoqvf4RZSvXugl8Xh5IB26U70kV+3kp9C/2KGSmrskEuaah6Ny cVU8nacbVhapEpRpsYk4O2w2ytLRU84Fni7Fd3WMlnV14/yLFa8gfEtYHmuMzepEmP2PB+Yv6 Pd39Uk2tcTpxAxw3edQm/Lxi5x8k5UkeFWXXZ6xP5fp2Kq3+yngHR1Btx4c0dAuKslCh7Aaso 2YaJ54oqBAB1F6TCSaCwJyDBbxYRg3U+gS3ZYlA6/VO+EtOlya1LdNNv465V8Kkkg7KlQTdpI wbLXfWsxTaS8dfzr8zW8h4K7V8tuyBk+zMqdnxFBu+JcnX5J4thBemdLo8i0JDAtViUld7Xiq fYjpyegN7/VJhH/jmfwKVt7zWSzLOoFhB3UJcss2DezLGJmoSaRKKvL2f+I= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP using ceph_pagelist_encode_string() instead of combination of ceph_pagelist_encode_32() and ceph_pagelist_append() when encoding string. Signed-off-by: Chengguang Xu --- fs/ceph/acl.c | 6 ++---- net/ceph/osd_client.c | 11 ++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index f736108604a6..af18cacab56f 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -229,8 +229,7 @@ int ceph_pre_init_acls(struct inode *dir, umode_t *mode, tmp_buf, val_size1); if (err < 0) goto out_err; - ceph_pagelist_encode_32(pagelist, val_size1); - ceph_pagelist_append(pagelist, tmp_buf, val_size1); + ceph_pagelist_encode_string(pagelist, tmp_buf, val_size1); } if (default_acl) { size_t len = strlen(XATTR_NAME_POSIX_ACL_DEFAULT); @@ -244,8 +243,7 @@ int ceph_pre_init_acls(struct inode *dir, umode_t *mode, tmp_buf, val_size2); if (err < 0) goto out_err; - ceph_pagelist_encode_32(pagelist, val_size2); - ceph_pagelist_append(pagelist, tmp_buf, val_size2); + ceph_pagelist_encode_string(pagelist, tmp_buf, val_size2); } kfree(tmp_buf); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index f2584fe1246f..e895f102dd33 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -4607,12 +4607,10 @@ static int osd_req_op_notify_ack_init(struct ceph_osd_request *req, int which, ceph_pagelist_init(pl); ret = ceph_pagelist_encode_64(pl, notify_id); ret |= ceph_pagelist_encode_64(pl, cookie); - if (payload) { - ret |= ceph_pagelist_encode_32(pl, payload_len); - ret |= ceph_pagelist_append(pl, payload, payload_len); - } else { + if (payload) + ret |= ceph_pagelist_encode_string(pl, payload, payload_len); + else ret |= ceph_pagelist_encode_32(pl, 0); - } if (ret) { ceph_pagelist_release(pl); return -ENOMEM; @@ -4678,8 +4676,7 @@ static int osd_req_op_notify_init(struct ceph_osd_request *req, int which, ceph_pagelist_init(pl); ret = ceph_pagelist_encode_32(pl, 1); /* prot_ver */ ret |= ceph_pagelist_encode_32(pl, timeout); - ret |= ceph_pagelist_encode_32(pl, payload_len); - ret |= ceph_pagelist_append(pl, payload, payload_len); + ret |= ceph_pagelist_encode_string(pl, payload, payload_len); if (ret) { ceph_pagelist_release(pl); return -ENOMEM;