static bool lease_breaking(struct file_lock *fl)
{
- return fl->fl_type & F_INPROGRESS;
+ return fl->fl_flags & FL_INPROGRESS;
}
int leases_enable = 1;
if (error)
return error;
+ fl->fl_flags &= ~FL_INPROGRESS;
locks_wake_up_blocks(fl);
if (arg == F_UNLCK)
locks_delete_lock(before);
before = &fl->fl_next;
continue;
}
- lease_modify(before, fl->fl_type & ~F_INPROGRESS);
+ lease_modify(before, fl->fl_type);
if (fl == *before) /* lease_modify may have freed fl */
before = &fl->fl_next;
}
if (want_write) {
/* If we want write access, we have to revoke any lease. */
- future = F_UNLCK | F_INPROGRESS;
+ future = F_UNLCK;
} else if (lease_breaking(flock)) {
/* If the lease is already being broken, we just leave it */
future = flock->fl_type;
} else if (flock->fl_type & F_WRLCK) {
/* Downgrade the exclusive lease to a read-only lease. */
- future = F_RDLCK | F_INPROGRESS;
+ future = F_RDLCK;
} else {
/* the existing lease was read-only, so we can read too. */
goto out;
for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
if (fl->fl_type != future) {
fl->fl_type = future;
+ fl->fl_flags |= FL_INPROGRESS;
fl->fl_break_time = break_time;
/* lease must have lmops break callback */
fl->fl_lmops->lm_break(fl);
for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl);
fl = fl->fl_next) {
if (fl->fl_file == filp) {
- type = fl->fl_type & ~F_INPROGRESS;
+ type = fl->fl_type;
break;
}
}
before = &fl->fl_next) {
if (fl->fl_file == filp)
my_before = before;
- else if (fl->fl_type == (F_INPROGRESS | F_UNLCK))
+ else if ((fl->fl_type == F_UNLCK) && lease_breaking(fl))
/*
* Someone is in the process of opening this
* file for writing so we may not take an
#define FL_LEASE 32 /* lease held on this file */
#define FL_CLOSE 64 /* unlock on close */
#define FL_SLEEP 128 /* A blocking lock */
+#define FL_INPROGRESS 256 /* Lease is being broken */
/*
* Special return value from posix_lock_file() and vfs_lock_file() for
struct list_head fl_link; /* doubly linked list of all locks */
struct list_head fl_block; /* circular list of blocked processes */
fl_owner_t fl_owner;
- unsigned char fl_flags;
+ unsigned int fl_flags;
unsigned char fl_type;
unsigned int fl_pid;
struct pid *fl_nspid;