194
* Encode the flock and fcntl locks for the given inode into the pagelist.
195
* Format is: #fcntl locks, sequential fcntl locks, #flock locks,
196
* sequential flock locks.
197
* Must be called with lock_flocks() already held.
198
* If we encounter more of a specific lock type than expected,
199
* we return the value 1.
194
* Encode the flock and fcntl locks for the given inode into the ceph_filelock
195
* array. Must be called with lock_flocks() already held.
196
* If we encounter more of a specific lock type than expected, return -ENOSPC.
201
int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist,
202
int num_fcntl_locks, int num_flock_locks)
198
int ceph_encode_locks_to_buffer(struct inode *inode,
199
struct ceph_filelock *flocks,
200
int num_fcntl_locks, int num_flock_locks)
204
202
struct file_lock *lock;
205
struct ceph_filelock cephlock;
207
204
int seen_fcntl = 0;
208
205
int seen_flock = 0;
210
208
dout("encoding %d flock and %d fcntl locks", num_flock_locks,
211
209
num_fcntl_locks);
212
err = ceph_pagelist_append(pagelist, &num_fcntl_locks, sizeof(u32));
215
211
for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
216
212
if (lock->fl_flags & FL_POSIX) {
222
err = lock_to_ceph_filelock(lock, &cephlock);
218
err = lock_to_ceph_filelock(lock, &flocks[l]);
225
err = ceph_pagelist_append(pagelist, &cephlock,
226
sizeof(struct ceph_filelock));
232
err = ceph_pagelist_append(pagelist, &num_flock_locks, sizeof(u32));
235
224
for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
236
225
if (lock->fl_flags & FL_FLOCK) {
242
err = lock_to_ceph_filelock(lock, &cephlock);
231
err = lock_to_ceph_filelock(lock, &flocks[l]);
245
err = ceph_pagelist_append(pagelist, &cephlock,
246
sizeof(struct ceph_filelock));
242
* Copy the encoded flock and fcntl locks into the pagelist.
243
* Format is: #fcntl locks, sequential fcntl locks, #flock locks,
244
* sequential flock locks.
245
* Returns zero on success.
247
int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
248
struct ceph_pagelist *pagelist,
249
int num_fcntl_locks, int num_flock_locks)
254
nlocks = cpu_to_le32(num_fcntl_locks);
255
err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
259
err = ceph_pagelist_append(pagelist, flocks,
260
num_fcntl_locks * sizeof(*flocks));
264
nlocks = cpu_to_le32(num_flock_locks);
265
err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
269
err = ceph_pagelist_append(pagelist,
270
&flocks[num_fcntl_locks],
271
num_flock_locks * sizeof(*flocks));
256
277
* Given a pointer to a lock, convert it to a ceph filelock