summaryrefslogtreecommitdiff
path: root/fs/ceph/locks.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2017-09-11 10:36:28 +0800
committerIlya Dryomov <idryomov@gmail.com>2017-11-13 12:11:27 +0100
commit4deb14a2593dfade102dd94a803a63cf620cfd56 (patch)
tree4d50d2b4f35e28106175ecef8ac5aca7bdf2a562 /fs/ceph/locks.c
parentc6db84723363790160a89dee4554ad2f0687a0c5 (diff)
ceph: optimize flock encoding during reconnect
Don't malloc if there is no flock. Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/locks.c')
-rw-r--r--fs/ceph/locks.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 2927f3bc2fc9..aaea82076849 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -431,19 +431,22 @@ int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
if (err)
goto out_fail;
- err = ceph_pagelist_append(pagelist, flocks,
- num_fcntl_locks * sizeof(*flocks));
- if (err)
- goto out_fail;
+ if (num_fcntl_locks > 0) {
+ err = ceph_pagelist_append(pagelist, flocks,
+ num_fcntl_locks * sizeof(*flocks));
+ if (err)
+ goto out_fail;
+ }
nlocks = cpu_to_le32(num_flock_locks);
err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
if (err)
goto out_fail;
- err = ceph_pagelist_append(pagelist,
- &flocks[num_fcntl_locks],
- num_flock_locks * sizeof(*flocks));
+ if (num_flock_locks > 0) {
+ err = ceph_pagelist_append(pagelist, &flocks[num_fcntl_locks],
+ num_flock_locks * sizeof(*flocks));
+ }
out_fail:
return err;
}