Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

filelock: make lease_alloc() take a flags argument

__break_lease() currently overrides the flc_flags field in the lease
after allocating it. A forthcoming patch will add the ability to request
a FL_DELEG type lease.

Instead of overriding the flags field, add a flags argument to
lease_alloc() and lease_init() so it's set correctly after allocating.

Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20251111-dir-deleg-ro-v6-1-52f3feebb2f2@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jeff Layton and committed by
Christian Brauner
6fc5f2b1 3a866087

+6 -7
+6 -7
fs/locks.c
··· 585 585 /* 586 586 * Initialize a lease, use the default lock manager operations 587 587 */ 588 - static int lease_init(struct file *filp, int type, struct file_lease *fl) 588 + static int lease_init(struct file *filp, unsigned int flags, int type, struct file_lease *fl) 589 589 { 590 590 if (assign_type(&fl->c, type) != 0) 591 591 return -EINVAL; ··· 594 594 fl->c.flc_pid = current->tgid; 595 595 596 596 fl->c.flc_file = filp; 597 - fl->c.flc_flags = FL_LEASE; 597 + fl->c.flc_flags = flags; 598 598 fl->fl_lmops = &lease_manager_ops; 599 599 return 0; 600 600 } 601 601 602 602 /* Allocate a file_lock initialised to this type of lease */ 603 - static struct file_lease *lease_alloc(struct file *filp, int type) 603 + static struct file_lease *lease_alloc(struct file *filp, unsigned int flags, int type) 604 604 { 605 605 struct file_lease *fl = locks_alloc_lease(); 606 606 int error = -ENOMEM; ··· 608 608 if (fl == NULL) 609 609 return ERR_PTR(error); 610 610 611 - error = lease_init(filp, type, fl); 611 + error = lease_init(filp, flags, type, fl); 612 612 if (error) { 613 613 locks_free_lease(fl); 614 614 return ERR_PTR(error); ··· 1548 1548 int want_write = (mode & O_ACCMODE) != O_RDONLY; 1549 1549 LIST_HEAD(dispose); 1550 1550 1551 - new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); 1551 + new_fl = lease_alloc(NULL, type, want_write ? F_WRLCK : F_RDLCK); 1552 1552 if (IS_ERR(new_fl)) 1553 1553 return PTR_ERR(new_fl); 1554 - new_fl->c.flc_flags = type; 1555 1554 1556 1555 /* typically we will check that ctx is non-NULL before calling */ 1557 1556 ctx = locks_inode_context(inode); ··· 2032 2033 struct fasync_struct *new; 2033 2034 int error; 2034 2035 2035 - fl = lease_alloc(filp, arg); 2036 + fl = lease_alloc(filp, FL_LEASE, arg); 2036 2037 if (IS_ERR(fl)) 2037 2038 return PTR_ERR(fl); 2038 2039