diff options
author | Yan, Zheng <zyan@redhat.com> | 2017-09-11 05:36:28 +0300 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-11-13 14:11:27 +0300 |
commit | 4deb14a2593dfade102dd94a803a63cf620cfd56 (patch) | |
tree | 4d50d2b4f35e28106175ecef8ac5aca7bdf2a562 /fs/ceph/locks.c | |
parent | c6db84723363790160a89dee4554ad2f0687a0c5 (diff) | |
download | linux-4deb14a2593dfade102dd94a803a63cf620cfd56.tar.xz |
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.c | 17 |
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; } |