]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix posix file locking (6/9)
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 07:14:03 +0000 (00:14 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 23 Aug 2004 07:14:03 +0000 (00:14 -0700)
VFS: get rid of the fl_notify, fl_insert, fl_remove fields from
   struct file_lock. They belong in the new lock_manager_operations
   structure.

Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/lockd/svclock.c
fs/locks.c
include/linux/fs.h

index 99dab7477d5e90f803eb57bed44ecc6a60aefb0a..f38fb7e0981ad5de65fc95c568225f02ebbccb4b 100644 (file)
@@ -42,7 +42,6 @@
 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
@@ -193,7 +192,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file,
                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 */
 
@@ -487,6 +485,7 @@ static int nlmsvc_same_owner(struct file_lock *fl1, struct file_lock *fl2)
 
 struct lock_manager_operations nlmsvc_lock_operations = {
        .fl_compare_owner = nlmsvc_same_owner,
+       .fl_notify = nlmsvc_notify_blocked,
 };
 
 /*
index 4b16affb806205ff875ce09ed8080977ca0d37d3..d53677ada954c6e91c347e2a6a3775953a6d7383 100644 (file)
@@ -190,9 +190,6 @@ void locks_init_lock(struct file_lock *fl)
        fl->fl_flags = 0;
        fl->fl_type = 0;
        fl->fl_start = fl->fl_end = 0;
-       fl->fl_notify = NULL;
-       fl->fl_insert = NULL;
-       fl->fl_remove = NULL;
        fl->fl_ops = NULL;
        fl->fl_lmops = NULL;
 }
@@ -226,9 +223,6 @@ void locks_copy_lock(struct file_lock *new, struct file_lock *fl)
        new->fl_type = fl->fl_type;
        new->fl_start = fl->fl_start;
        new->fl_end = fl->fl_end;
-       new->fl_notify = fl->fl_notify;
-       new->fl_insert = fl->fl_insert;
-       new->fl_remove = fl->fl_remove;
        new->fl_ops = fl->fl_ops;
        new->fl_lmops = fl->fl_lmops;
        if (fl->fl_ops && fl->fl_ops->fl_copy_lock)
@@ -333,9 +327,6 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
        fl->fl_pid = current->tgid;
        fl->fl_file = filp;
        fl->fl_flags = FL_POSIX;
-       fl->fl_notify = NULL;
-       fl->fl_insert = NULL;
-       fl->fl_remove = NULL;
        fl->fl_ops = NULL;
        fl->fl_lmops = NULL;
 
@@ -375,9 +366,6 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
        fl->fl_pid = current->tgid;
        fl->fl_file = filp;
        fl->fl_flags = FL_POSIX;
-       fl->fl_notify = NULL;
-       fl->fl_insert = NULL;
-       fl->fl_remove = NULL;
        fl->fl_ops = NULL;
        fl->fl_lmops = NULL;
 
@@ -413,9 +401,6 @@ static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
        }
        fl->fl_start = 0;
        fl->fl_end = OFFSET_MAX;
-       fl->fl_notify = NULL;
-       fl->fl_insert = NULL;
-       fl->fl_remove = NULL;
        fl->fl_ops = NULL;
        fl->fl_lmops = NULL;
 
@@ -491,8 +476,8 @@ static void locks_wake_up_blocks(struct file_lock *blocker)
                struct file_lock *waiter = list_entry(blocker->fl_block.next,
                                struct file_lock, fl_block);
                __locks_delete_block(waiter);
-               if (waiter->fl_notify)
-                       waiter->fl_notify(waiter);
+               if (waiter->fl_lmops && waiter->fl_lmops->fl_notify)
+                       waiter->fl_lmops->fl_notify(waiter);
                else
                        wake_up(&waiter->fl_wait);
        }
@@ -509,8 +494,8 @@ static void locks_insert_lock(struct file_lock **pos, struct file_lock *fl)
        fl->fl_next = *pos;
        *pos = fl;
 
-       if (fl->fl_insert)
-               fl->fl_insert(fl);
+       if (fl->fl_ops && fl->fl_ops->fl_insert)
+               fl->fl_ops->fl_insert(fl);
 }
 
 /*
@@ -533,8 +518,8 @@ static void locks_delete_lock(struct file_lock **thisfl_p)
                fl->fl_fasync = NULL;
        }
 
-       if (fl->fl_remove)
-               fl->fl_remove(fl);
+       if (fl->fl_ops && fl->fl_ops->fl_remove)
+               fl->fl_ops->fl_remove(fl);
 
        locks_wake_up_blocks(fl);
        locks_free_lock(fl);
index cc2bbd2fb0c64c369a35779dc232a7125abc4fa4..2413530b359175e9a4a2cd5ecc53f30e9aa36432 100644 (file)
@@ -623,12 +623,15 @@ extern spinlock_t files_lock;
 typedef struct files_struct *fl_owner_t;
 
 struct file_lock_operations {
+       void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
+       void (*fl_remove)(struct file_lock *);  /* lock removal callback */
        void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
        void (*fl_release_private)(struct file_lock *);
 };
 
 struct lock_manager_operations {
        int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
+       void (*fl_notify)(struct file_lock *);  /* unblock callback */
 };
 
 /* that will die - we need it for nfs_lock_info */
@@ -647,10 +650,6 @@ struct file_lock {
        loff_t fl_start;
        loff_t fl_end;
 
-       void (*fl_notify)(struct file_lock *);  /* unblock callback */
-       void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
-       void (*fl_remove)(struct file_lock *);  /* lock removal callback */
-
        struct fasync_struct *  fl_fasync; /* for lease break notifications */
        unsigned long fl_break_time;    /* for nonblocking lease breaks */