Commit c420276a532a10ef59849adc2681f45306166b89

Authored by Jim Schutt
Committed by Alex Elder
1 parent 14d2f38df6

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>

Showing 2 changed files with 6 additions and 3 deletions Side-by-side Diff

... ... @@ -206,10 +206,12 @@
206 206 int err = 0;
207 207 int seen_fcntl = 0;
208 208 int seen_flock = 0;
  209 + __le32 nlocks;
209 210  
210 211 dout("encoding %d flock and %d fcntl locks", num_flock_locks,
211 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 215 if (err)
214 216 goto fail;
215 217 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
... ... @@ -229,7 +231,8 @@
229 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 236 if (err)
234 237 goto fail;
235 238 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
fs/ceph/mds_client.c
... ... @@ -2485,7 +2485,7 @@
2485 2485 lock_flocks();
2486 2486 ceph_count_locks(inode, &num_fcntl_locks,
2487 2487 &num_flock_locks);
2488   - rec.v2.flock_len = (2*sizeof(u32) +
  2488 + rec.v2.flock_len = cpu_to_le32(2*sizeof(u32) +
2489 2489 (num_fcntl_locks+num_flock_locks) *
2490 2490 sizeof(struct ceph_filelock));
2491 2491 unlock_flocks();