locks.c (269a6194dcbaa5d8e61f32000486fc0f2acf08d0) | locks.c (d9077f7bad141df143cc4fa000a68a868bcea7c0) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/locks.c 4 * 5 * We implement four types of file locks: BSD locks, posix locks, open 6 * file description locks, and leases. For details about BSD locks, 7 * see the flock(2) man page; for details about the other three, see 8 * fcntl(2). --- 425 unchanged lines hidden (view full) --- 434 fl->c.flc_file = filp; 435 fl->c.flc_owner = filp; 436 fl->c.flc_pid = current->tgid; 437 fl->c.flc_flags = FL_FLOCK; 438 fl->c.flc_type = type; 439 fl->fl_end = OFFSET_MAX; 440} 441 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/locks.c 4 * 5 * We implement four types of file locks: BSD locks, posix locks, open 6 * file description locks, and leases. For details about BSD locks, 7 * see the flock(2) man page; for details about the other three, see 8 * fcntl(2). --- 425 unchanged lines hidden (view full) --- 434 fl->c.flc_file = filp; 435 fl->c.flc_owner = filp; 436 fl->c.flc_pid = current->tgid; 437 fl->c.flc_flags = FL_FLOCK; 438 fl->c.flc_type = type; 439 fl->fl_end = OFFSET_MAX; 440} 441 |
442static int assign_type(struct file_lock *fl, int type) | 442static int assign_type(struct file_lock_core *flc, int type) |
443{ 444 switch (type) { 445 case F_RDLCK: 446 case F_WRLCK: 447 case F_UNLCK: | 443{ 444 switch (type) { 445 case F_RDLCK: 446 case F_WRLCK: 447 case F_UNLCK: |
448 fl->c.flc_type = type; | 448 flc->flc_type = type; |
449 break; 450 default: 451 return -EINVAL; 452 } 453 return 0; 454} 455 456static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, --- 35 unchanged lines hidden (view full) --- 492 493 fl->c.flc_owner = current->files; 494 fl->c.flc_pid = current->tgid; 495 fl->c.flc_file = filp; 496 fl->c.flc_flags = FL_POSIX; 497 fl->fl_ops = NULL; 498 fl->fl_lmops = NULL; 499 | 449 break; 450 default: 451 return -EINVAL; 452 } 453 return 0; 454} 455 456static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, --- 35 unchanged lines hidden (view full) --- 492 493 fl->c.flc_owner = current->files; 494 fl->c.flc_pid = current->tgid; 495 fl->c.flc_file = filp; 496 fl->c.flc_flags = FL_POSIX; 497 fl->fl_ops = NULL; 498 fl->fl_lmops = NULL; 499 |
500 return assign_type(fl, l->l_type); | 500 return assign_type(&fl->c, l->l_type); |
501} 502 503/* Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX 504 * style lock. 505 */ 506static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, 507 struct flock *l) 508{ --- 38 unchanged lines hidden (view full) --- 547 .lm_setup = lease_setup, 548}; 549 550/* 551 * Initialize a lease, use the default lock manager operations 552 */ 553static int lease_init(struct file *filp, int type, struct file_lock *fl) 554{ | 501} 502 503/* Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX 504 * style lock. 505 */ 506static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, 507 struct flock *l) 508{ --- 38 unchanged lines hidden (view full) --- 547 .lm_setup = lease_setup, 548}; 549 550/* 551 * Initialize a lease, use the default lock manager operations 552 */ 553static int lease_init(struct file *filp, int type, struct file_lock *fl) 554{ |
555 if (assign_type(fl, type) != 0) | 555 if (assign_type(&fl->c, type) != 0) |
556 return -EINVAL; 557 558 fl->c.flc_owner = filp; 559 fl->c.flc_pid = current->tgid; 560 561 fl->c.flc_file = filp; 562 fl->c.flc_flags = FL_LEASE; 563 fl->fl_start = 0; --- 840 unchanged lines hidden (view full) --- 1404 case F_RDLCK: 1405 fl->c.flc_flags &= ~FL_DOWNGRADE_PENDING; 1406 } 1407} 1408 1409/* We already had a lease on this file; just change its type */ 1410int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) 1411{ | 556 return -EINVAL; 557 558 fl->c.flc_owner = filp; 559 fl->c.flc_pid = current->tgid; 560 561 fl->c.flc_file = filp; 562 fl->c.flc_flags = FL_LEASE; 563 fl->fl_start = 0; --- 840 unchanged lines hidden (view full) --- 1404 case F_RDLCK: 1405 fl->c.flc_flags &= ~FL_DOWNGRADE_PENDING; 1406 } 1407} 1408 1409/* We already had a lease on this file; just change its type */ 1410int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) 1411{ |
1412 int error = assign_type(fl, arg); | 1412 int error = assign_type(&fl->c, arg); |
1413 1414 if (error) 1415 return error; 1416 lease_clear_pending(fl, arg); 1417 locks_wake_up_blocks(fl); 1418 if (arg == F_UNLCK) { 1419 struct file *filp = fl->c.flc_file; 1420 --- 1538 unchanged lines hidden --- | 1413 1414 if (error) 1415 return error; 1416 lease_clear_pending(fl, arg); 1417 locks_wake_up_blocks(fl); 1418 if (arg == F_UNLCK) { 1419 struct file *filp = fl->c.flc_file; 1420 --- 1538 unchanged lines hidden --- |