fl->fl_type = type;
fl->fl_end = OFFSET_MAX;
- /* check agains file xid maybe ? */
+ /* check against file xid maybe ? */
fl->fl_xid = vx_current_xid();
vx_locks_inc(fl);
fl->fl_file->f_owner.signum = 0;
}
-struct lock_manager_operations lease_manager_ops = {
+static int lease_mylease_callback(struct file_lock *fl, struct file_lock *try)
+{
+ return fl->fl_file == try->fl_file;
+}
+
+static struct lock_manager_operations lease_manager_ops = {
.fl_break = lease_break_callback,
.fl_release_private = lease_release_private_callback,
+ .fl_mylease = lease_mylease_callback,
+ .fl_change = lease_modify,
};
/*
EXPORT_SYMBOL(locks_mandatory_area);
/* We already had a lease on this file; just change its type */
-static int lease_modify(struct file_lock **before, int arg)
+int lease_modify(struct file_lock **before, int arg)
{
struct file_lock *fl = *before;
int error = assign_type(fl, arg);
return 0;
}
+EXPORT_SYMBOL(lease_modify);
+
static void time_out_leases(struct inode *inode)
{
struct file_lock **before;
}
}
- /**
-* remove_lease - let time_out_leases remove the lease.
-* @@file_lock: the lease to remove
-*/
-void remove_lease(struct file_lock *fl)
-{
- lock_kernel();
- if (!fl || !IS_LEASE(fl))
- goto out;
- fl->fl_type = F_UNLCK | F_INPROGRESS;
- fl->fl_break_time = jiffies - 10;
- time_out_leases(fl->fl_file->f_dentry->d_inode);
-out:
- unlock_kernel();
-}
-
-EXPORT_SYMBOL(remove_lease);
-
/**
* __break_lease - revoke all outstanding leases on file
* @inode: the inode of the file to return
if (fl->fl_type != future) {
fl->fl_type = future;
fl->fl_break_time = break_time;
- if (fl->fl_lmops && fl->fl_lmops->fl_break)
- fl->fl_lmops->fl_break(fl);
- else /* lease must have lmops break callback */
- BUG();
+ /* lease must have lmops break callback */
+ fl->fl_lmops->fl_break(fl);
}
}
*
* Called with kernel lock held.
*/
-int __setlease(struct file *filp, long arg, struct file_lock **flp)
+static int __setlease(struct file *filp, long arg, struct file_lock **flp)
{
struct file_lock *fl, **before, **my_before = NULL, *lease = *flp;
struct dentry *dentry = filp->f_dentry;
for (before = &inode->i_flock;
((fl = *before) != NULL) && IS_LEASE(fl);
before = &fl->fl_next) {
- if (fl->fl_file == filp)
+ if (lease->fl_lmops->fl_mylease(fl, lease))
my_before = before;
else if (fl->fl_type == (F_INPROGRESS | F_UNLCK))
/*
goto out;
if (my_before != NULL) {
- error = lease_modify(my_before, arg);
+ error = lease->fl_lmops->fl_change(my_before, arg);
goto out;
}
return;
if (filp->f_op && filp->f_op->flock) {
- struct file_lock fl = { .fl_flags = FL_FLOCK,
- .fl_type = F_UNLCK };
+ struct file_lock fl = {
+ .fl_pid = current->tgid,
+ .fl_file = filp,
+ .fl_flags = FL_FLOCK,
+ .fl_type = F_UNLCK,
+ .fl_end = OFFSET_MAX,
+ };
filp->f_op->flock(filp, F_SETLKW, &fl);
}