~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to fs/ceph/locks.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2013-07-11 18:35:20 UTC
  • Revision ID: package-import@ubuntu.com-20130711183520-htnf1x4y5r11hndr
Tags: 3.5.0-229.42
* Release Tracking Bug
  - LP: #1199276

[ Paolo Pisati ]

* [Config] CONFIG_ATH9K_LEGACY_RATE_CONTROL is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
}
192
192
 
193
193
/**
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.
200
197
 */
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)
203
201
{
204
202
        struct file_lock *lock;
205
 
        struct ceph_filelock cephlock;
206
203
        int err = 0;
207
204
        int seen_fcntl = 0;
208
205
        int seen_flock = 0;
 
206
        int l = 0;
209
207
 
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));
213
 
        if (err)
214
 
                goto fail;
 
210
 
215
211
        for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
216
212
                if (lock->fl_flags & FL_POSIX) {
217
213
                        ++seen_fcntl;
219
215
                                err = -ENOSPC;
220
216
                                goto fail;
221
217
                        }
222
 
                        err = lock_to_ceph_filelock(lock, &cephlock);
 
218
                        err = lock_to_ceph_filelock(lock, &flocks[l]);
223
219
                        if (err)
224
220
                                goto fail;
225
 
                        err = ceph_pagelist_append(pagelist, &cephlock,
226
 
                                           sizeof(struct ceph_filelock));
 
221
                        ++l;
227
222
                }
228
 
                if (err)
229
 
                        goto fail;
230
223
        }
231
 
 
232
 
        err = ceph_pagelist_append(pagelist, &num_flock_locks, sizeof(u32));
233
 
        if (err)
234
 
                goto fail;
235
224
        for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
236
225
                if (lock->fl_flags & FL_FLOCK) {
237
226
                        ++seen_flock;
239
228
                                err = -ENOSPC;
240
229
                                goto fail;
241
230
                        }
242
 
                        err = lock_to_ceph_filelock(lock, &cephlock);
 
231
                        err = lock_to_ceph_filelock(lock, &flocks[l]);
243
232
                        if (err)
244
233
                                goto fail;
245
 
                        err = ceph_pagelist_append(pagelist, &cephlock,
246
 
                                           sizeof(struct ceph_filelock));
 
234
                        ++l;
247
235
                }
248
 
                if (err)
249
 
                        goto fail;
250
236
        }
251
237
fail:
252
238
        return err;
253
239
}
254
240
 
 
241
/**
 
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.
 
246
 */
 
247
int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
 
248
                           struct ceph_pagelist *pagelist,
 
249
                           int num_fcntl_locks, int num_flock_locks)
 
250
{
 
251
        int err = 0;
 
252
        __le32 nlocks;
 
253
 
 
254
        nlocks = cpu_to_le32(num_fcntl_locks);
 
255
        err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
 
256
        if (err)
 
257
                goto out_fail;
 
258
 
 
259
        err = ceph_pagelist_append(pagelist, flocks,
 
260
                                   num_fcntl_locks * sizeof(*flocks));
 
261
        if (err)
 
262
                goto out_fail;
 
263
 
 
264
        nlocks = cpu_to_le32(num_flock_locks);
 
265
        err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
 
266
        if (err)
 
267
                goto out_fail;
 
268
 
 
269
        err = ceph_pagelist_append(pagelist,
 
270
                                   &flocks[num_fcntl_locks],
 
271
                                   num_flock_locks * sizeof(*flocks));
 
272
out_fail:
 
273
        return err;
 
274
}
 
275
 
255
276
/*
256
277
 * Given a pointer to a lock, convert it to a ceph filelock
257
278
 */