diff mbox

[3/3] ceph: use ceph_pagelist_encode_string() for encoding string

Message ID 20180623125524.29233-3-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu June 23, 2018, 12:55 p.m. UTC
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 <cgxu519@gmx.com>
---
 fs/ceph/acl.c         |  6 ++----
 net/ceph/osd_client.c | 11 ++++-------
 2 files changed, 6 insertions(+), 11 deletions(-)
diff mbox

Patch

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;