diff options
author | Jim Schutt <jaschut@sandia.gov> | 2013-05-15 14:03:35 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2013-05-17 13:45:43 -0400 |
commit | c420276a532a10ef59849adc2681f45306166b89 (patch) | |
tree | 2930964454c9e6e83709d5f96407a4b53a7e6f65 /fs | |
parent | 14d2f38df67fadee34625fcbd282ee22514c4846 (diff) |
ceph: add cpu_to_le32() calls when encoding a reconnect capability
In his review, Alex Elder mentioned that he hadn't checked that
num_fcntl_locks and num_flock_locks were properly decoded on the
server side, from a le32 over-the-wire type to a cpu type.
I checked, and AFAICS it is done; those interested can consult
Locker::_do_cap_update()
in src/mds/Locker.cc and src/include/encoding.h in the Ceph server
code (git://github.com/ceph/ceph).
I also checked the server side for flock_len decoding, and I believe
that also happens correctly, by virtue of having been declared
__le32 in struct ceph_mds_cap_reconnect, in src/include/ceph_fs.h.
Cc: stable@vger.kernel.org # 3.4+
Signed-off-by: Jim Schutt <jaschut@sandia.gov>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/locks.c | 7 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c index 202dd3d68be0..a80ed18d64ff 100644 --- a/fs/ceph/locks.c +++ b/fs/ceph/locks.c | |||
@@ -206,10 +206,12 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist, | |||
206 | int err = 0; | 206 | int err = 0; |
207 | int seen_fcntl = 0; | 207 | int seen_fcntl = 0; |
208 | int seen_flock = 0; | 208 | int seen_flock = 0; |
209 | __le32 nlocks; | ||
209 | 210 | ||
210 | dout("encoding %d flock and %d fcntl locks", num_flock_locks, | 211 | dout("encoding %d flock and %d fcntl locks", num_flock_locks, |
211 | num_fcntl_locks); | 212 | num_fcntl_locks); |
212 | err = ceph_pagelist_append(pagelist, &num_fcntl_locks, sizeof(u32)); | 213 | nlocks = cpu_to_le32(num_fcntl_locks); |
214 | err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks)); | ||
213 | if (err) | 215 | if (err) |
214 | goto fail; | 216 | goto fail; |
215 | for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { | 217 | for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { |
@@ -229,7 +231,8 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist, | |||
229 | goto fail; | 231 | goto fail; |
230 | } | 232 | } |
231 | 233 | ||
232 | err = ceph_pagelist_append(pagelist, &num_flock_locks, sizeof(u32)); | 234 | nlocks = cpu_to_le32(num_flock_locks); |
235 | err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks)); | ||
233 | if (err) | 236 | if (err) |
234 | goto fail; | 237 | goto fail; |
235 | for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { | 238 | for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 4f22671a5bd4..d9ca15255477 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2485,7 +2485,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap, | |||
2485 | lock_flocks(); | 2485 | lock_flocks(); |
2486 | ceph_count_locks(inode, &num_fcntl_locks, | 2486 | ceph_count_locks(inode, &num_fcntl_locks, |
2487 | &num_flock_locks); | 2487 | &num_flock_locks); |
2488 | rec.v2.flock_len = (2*sizeof(u32) + | 2488 | rec.v2.flock_len = cpu_to_le32(2*sizeof(u32) + |
2489 | (num_fcntl_locks+num_flock_locks) * | 2489 | (num_fcntl_locks+num_flock_locks) * |
2490 | sizeof(struct ceph_filelock)); | 2490 | sizeof(struct ceph_filelock)); |
2491 | unlock_flocks(); | 2491 | unlock_flocks(); |