aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/addr.c2
-rw-r--r--fs/ceph/locks.c64
-rw-r--r--fs/ceph/mds_client.c4
3 files changed, 33 insertions, 37 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f5013d92a7e6..c81c0e004588 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1416,7 +1416,7 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 dout("fill_inline_data %p %llx.%llx len %lu locked_page %p\n", 1419 dout("fill_inline_data %p %llx.%llx len %zu locked_page %p\n",
1420 inode, ceph_vinop(inode), len, locked_page); 1420 inode, ceph_vinop(inode), len, locked_page);
1421 1421
1422 if (len > 0) { 1422 if (len > 0) {
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index c35c5c614e38..06ea5cd05cd9 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -239,23 +239,21 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
239 return err; 239 return err;
240} 240}
241 241
242/** 242/*
243 * Must be called with lock_flocks() already held. Fills in the passed 243 * Fills in the passed counter variables, so you can prepare pagelist metadata
244 * counter variables, so you can prepare pagelist metadata before calling 244 * before calling ceph_encode_locks.
245 * ceph_encode_locks.
246 */ 245 */
247void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count) 246void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
248{ 247{
249 struct file_lock *lock; 248 struct file_lock_context *ctx;
250 249
251 *fcntl_count = 0; 250 *fcntl_count = 0;
252 *flock_count = 0; 251 *flock_count = 0;
253 252
254 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { 253 ctx = inode->i_flctx;
255 if (lock->fl_flags & FL_POSIX) 254 if (ctx) {
256 ++(*fcntl_count); 255 *fcntl_count = ctx->flc_posix_cnt;
257 else if (lock->fl_flags & FL_FLOCK) 256 *flock_count = ctx->flc_flock_cnt;
258 ++(*flock_count);
259 } 257 }
260 dout("counted %d flock locks and %d fcntl locks", 258 dout("counted %d flock locks and %d fcntl locks",
261 *flock_count, *fcntl_count); 259 *flock_count, *fcntl_count);
@@ -271,6 +269,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
271 int num_fcntl_locks, int num_flock_locks) 269 int num_fcntl_locks, int num_flock_locks)
272{ 270{
273 struct file_lock *lock; 271 struct file_lock *lock;
272 struct file_lock_context *ctx = inode->i_flctx;
274 int err = 0; 273 int err = 0;
275 int seen_fcntl = 0; 274 int seen_fcntl = 0;
276 int seen_flock = 0; 275 int seen_flock = 0;
@@ -279,33 +278,34 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
279 dout("encoding %d flock and %d fcntl locks", num_flock_locks, 278 dout("encoding %d flock and %d fcntl locks", num_flock_locks,
280 num_fcntl_locks); 279 num_fcntl_locks);
281 280
282 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { 281 if (!ctx)
283 if (lock->fl_flags & FL_POSIX) { 282 return 0;
284 ++seen_fcntl; 283
285 if (seen_fcntl > num_fcntl_locks) { 284 spin_lock(&ctx->flc_lock);
286 err = -ENOSPC; 285 list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
287 goto fail; 286 ++seen_fcntl;
288 } 287 if (seen_fcntl > num_fcntl_locks) {
289 err = lock_to_ceph_filelock(lock, &flocks[l]); 288 err = -ENOSPC;
290 if (err) 289 goto fail;
291 goto fail;
292 ++l;
293 } 290 }
291 err = lock_to_ceph_filelock(lock, &flocks[l]);
292 if (err)
293 goto fail;
294 ++l;
294 } 295 }
295 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { 296 list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
296 if (lock->fl_flags & FL_FLOCK) { 297 ++seen_flock;
297 ++seen_flock; 298 if (seen_flock > num_flock_locks) {
298 if (seen_flock > num_flock_locks) { 299 err = -ENOSPC;
299 err = -ENOSPC; 300 goto fail;
300 goto fail;
301 }
302 err = lock_to_ceph_filelock(lock, &flocks[l]);
303 if (err)
304 goto fail;
305 ++l;
306 } 301 }
302 err = lock_to_ceph_filelock(lock, &flocks[l]);
303 if (err)
304 goto fail;
305 ++l;
307 } 306 }
308fail: 307fail:
308 spin_unlock(&ctx->flc_lock);
309 return err; 309 return err;
310} 310}
311 311
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index d2171f4a6980..5f62fb7a5d0a 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2700,20 +2700,16 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
2700 struct ceph_filelock *flocks; 2700 struct ceph_filelock *flocks;
2701 2701
2702encode_again: 2702encode_again:
2703 spin_lock(&inode->i_lock);
2704 ceph_count_locks(inode, &num_fcntl_locks, &num_flock_locks); 2703 ceph_count_locks(inode, &num_fcntl_locks, &num_flock_locks);
2705 spin_unlock(&inode->i_lock);
2706 flocks = kmalloc((num_fcntl_locks+num_flock_locks) * 2704 flocks = kmalloc((num_fcntl_locks+num_flock_locks) *
2707 sizeof(struct ceph_filelock), GFP_NOFS); 2705 sizeof(struct ceph_filelock), GFP_NOFS);
2708 if (!flocks) { 2706 if (!flocks) {
2709 err = -ENOMEM; 2707 err = -ENOMEM;
2710 goto out_free; 2708 goto out_free;
2711 } 2709 }
2712 spin_lock(&inode->i_lock);
2713 err = ceph_encode_locks_to_buffer(inode, flocks, 2710 err = ceph_encode_locks_to_buffer(inode, flocks,
2714 num_fcntl_locks, 2711 num_fcntl_locks,
2715 num_flock_locks); 2712 num_flock_locks);
2716 spin_unlock(&inode->i_lock);
2717 if (err) { 2713 if (err) {
2718 kfree(flocks); 2714 kfree(flocks);
2719 if (err == -ENOSPC) 2715 if (err == -ENOSPC)