The caller allocated it, the caller should free it.
The only issue so far is that we could change the flp pointer even on an
error return if the fl_change callback failed. But we can simply move
the flp assignment after the fl_change invocation, as the callers don't
care about the flp return value if the setlease call failed.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
knows that the file won't be changed on the server
by anyone else */
return generic_setlease(file, arg, lease);
- else {
- if (arg != F_UNLCK)
- locks_free_lock(*lease);
+ else
return -EAGAIN;
- }
}
struct file_system_type cifs_fs_type = {
static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
{
- if (arg != F_UNLCK)
- locks_free_lock(*fl);
return -EINVAL;
}
goto out;
if (my_before != NULL) {
- *flp = *my_before;
error = lease->fl_lmops->fl_change(my_before, arg);
+ if (!error)
+ *flp = *my_before;
goto out;
}
return 0;
out:
- if (arg != F_UNLCK)
- locks_free_lock(lease);
return error;
}
EXPORT_SYMBOL(generic_setlease);
}
lock_flocks();
error = __vfs_setlease(filp, arg, &fl);
- if (error)
- goto out_unlock;
+ if (error) {
+ unlock_flocks();
+ locks_free_lock(fl);
+ goto out_free_fasync;
+ }
/*
* fasync_insert_entry() returns the old entry if any.
fl->fl_type = F_UNLCK | F_INPROGRESS;
fl->fl_break_time = jiffies - 10;
time_out_leases(inode);
- goto out_unlock;
+ } else {
+ error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
}
-
- error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
-out_unlock:
unlock_flocks();
+
+out_free_fasync:
if (new)
fasync_free(new);
return error;
dprintk("NFS: setlease(%s/%s, arg=%ld)\n",
file->f_path.dentry->d_parent->d_name.name,
file->f_path.dentry->d_name.name, arg);
- if (arg != F_UNLCK)
- locks_free_lock(*fl);
return -EINVAL;
}
if ((status = vfs_setlease(fl->fl_file, fl->fl_type, &fl))) {
dprintk("NFSD: setlease failed [%d], no delegation\n", status);
dp->dl_flock = NULL;
+ locks_free_lock(fl);
unhash_delegation(dp);
flag = NFS4_OPEN_DELEGATE_NONE;
goto out;