static void nlmsvc_insert_block(struct nlm_block *block, unsigned long);
static int nlmsvc_remove_block(struct nlm_block *block);
static void nlmsvc_grant_callback(struct rpc_task *task);
-static void nlmsvc_notify_blocked(struct file_lock *);
/*
* The list of blocked locks to retry
goto failed_free;
/* Set notifier function for VFS, and init args */
- block->b_call.a_args.lock.fl.fl_notify = nlmsvc_notify_blocked;
+ block->b_call.a_args.lock.fl.fl_lmops = &nlmsvc_lock_operations;
block->b_call.a_args.cookie = *cookie; /* see above */
dprintk("lockd: created block %p...\n", block);
/* Remove block from list */
nlmsvc_remove_block(block);
- posix_unblock_lock(&file->f_file, fl);
- block->b_granted = 0;
+ if (fl->fl_next)
+ posix_unblock_lock(file->f_file, fl);
+ if (unlock) {
+ fl->fl_type = F_UNLCK;
+ posix_lock_file(file->f_file, fl);
+ block->b_granted = 0;
+ }
/* If the block is in the middle of a GRANT callback,
* don't kill it yet. */
int error;
dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
- file->f_file.f_dentry->d_inode->i_sb->s_id,
- file->f_file.f_dentry->d_inode->i_ino,
+ file->f_file->f_dentry->d_inode->i_sb->s_id,
+ file->f_file->f_dentry->d_inode->i_ino,
lock->fl.fl_type, lock->fl.fl_pid,
(long long)lock->fl.fl_start,
(long long)lock->fl.fl_end,
/* Lock file against concurrent access */
down(&file->f_sema);
- if (!(conflock = posix_test_lock(&file->f_file, &lock->fl))) {
- error = posix_lock_file(&file->f_file, &lock->fl);
+ if (!(conflock = posix_test_lock(file->f_file, &lock->fl))) {
+ error = posix_lock_file(file->f_file, &lock->fl);
if (block)
nlmsvc_delete_block(block, 0);
struct file_lock *fl;
dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
- file->f_file.f_dentry->d_inode->i_sb->s_id,
- file->f_file.f_dentry->d_inode->i_ino,
+ file->f_file->f_dentry->d_inode->i_sb->s_id,
+ file->f_file->f_dentry->d_inode->i_ino,
lock->fl.fl_type,
(long long)lock->fl.fl_start,
(long long)lock->fl.fl_end);
- if ((fl = posix_test_lock(&file->f_file, &lock->fl)) != NULL) {
+ if ((fl = posix_test_lock(file->f_file, &lock->fl)) != NULL) {
dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
fl->fl_type, (long long)fl->fl_start,
(long long)fl->fl_end);
int error;
dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
- file->f_file.f_dentry->d_inode->i_sb->s_id,
- file->f_file.f_dentry->d_inode->i_ino,
+ file->f_file->f_dentry->d_inode->i_sb->s_id,
+ file->f_file->f_dentry->d_inode->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
(long long)lock->fl.fl_end);
nlmsvc_cancel_blocked(file, lock);
lock->fl.fl_type = F_UNLCK;
- error = posix_lock_file(&file->f_file, &lock->fl);
+ error = posix_lock_file(file->f_file, &lock->fl);
return (error < 0)? nlm_lck_denied_nolocks : nlm_granted;
}
struct nlm_block *block;
dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
- file->f_file.f_dentry->d_inode->i_sb->s_id,
- file->f_file.f_dentry->d_inode->i_ino,
+ file->f_file->f_dentry->d_inode->i_sb->s_id,
+ file->f_file->f_dentry->d_inode->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
(long long)lock->fl.fl_end);
printk(KERN_WARNING "lockd: notification for unknown block!\n");
}
+static int nlmsvc_same_owner(struct file_lock *fl1, struct file_lock *fl2)
+{
+ return fl1->fl_owner == fl2->fl_owner && fl1->fl_pid == fl2->fl_pid;
+}
+
+struct lock_manager_operations nlmsvc_lock_operations = {
+ .fl_compare_owner = nlmsvc_same_owner,
+ .fl_notify = nlmsvc_notify_blocked,
+};
+
/*
* Try to claim a lock that was previously blocked.
*
}
/* Try the lock operation again */
- if ((conflock = posix_test_lock(&file->f_file, &lock->fl)) != NULL) {
+ if ((conflock = posix_test_lock(file->f_file, &lock->fl)) != NULL) {
/* Bummer, we blocked again */
dprintk("lockd: lock still blocked\n");
nlmsvc_insert_block(block, NLM_NEVER);
* following yields an error, this is most probably due to low
* memory. Retry the lock in a few seconds.
*/
- if ((error = posix_lock_file(&file->f_file, &lock->fl)) < 0) {
+ if ((error = posix_lock_file(file->f_file, &lock->fl)) < 0) {
printk(KERN_WARNING "lockd: unexpected error %d in %s!\n",
-error, __FUNCTION__);
nlmsvc_insert_block(block, 10 * HZ);