[PATCH 06/20] filelock: convert more internal functions to use file_lock_core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Convert more internal fs/locks.c functions to take and deal with struct
file_lock_core instead of struct file_lock:

- locks_dump_ctx_list
- locks_check_ctx_file_list
- locks_release_private
- locks_owner_has_blockers

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
 fs/locks.c | 51 +++++++++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 42221cecd331..e09920cc9da2 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -204,13 +204,12 @@ locks_get_lock_context(struct inode *inode, int type)
 static void
 locks_dump_ctx_list(struct list_head *list, char *list_type)
 {
-	struct file_lock *fl;
+	struct file_lock_core *flc;
 
-	list_for_each_entry(fl, list, fl_core.fl_list) {
-		pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type,
-			fl->fl_core.fl_owner, fl->fl_core.fl_flags,
-			fl->fl_core.fl_type, fl->fl_core.fl_pid);
-	}
+	list_for_each_entry(flc, list, fl_list)
+		pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
+			list_type, flc->fl_owner, flc->fl_flags,
+			flc->fl_type, flc->fl_pid);
 }
 
 static void
@@ -231,20 +230,19 @@ locks_check_ctx_lists(struct inode *inode)
 }
 
 static void
-locks_check_ctx_file_list(struct file *filp, struct list_head *list,
-				char *list_type)
+locks_check_ctx_file_list(struct file *filp, struct list_head *list, char *list_type)
 {
-	struct file_lock *fl;
+	struct file_lock_core *flc;
 	struct inode *inode = file_inode(filp);
 
-	list_for_each_entry(fl, list, fl_core.fl_list)
-		if (fl->fl_core.fl_file == filp)
+	list_for_each_entry(flc, list, fl_list)
+		if (flc->fl_file == filp)
 			pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx "
 				" fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
 				list_type, MAJOR(inode->i_sb->s_dev),
 				MINOR(inode->i_sb->s_dev), inode->i_ino,
-				fl->fl_core.fl_owner, fl->fl_core.fl_flags,
-				fl->fl_core.fl_type, fl->fl_core.fl_pid);
+				flc->fl_owner, flc->fl_flags,
+				flc->fl_type, flc->fl_pid);
 }
 
 void
@@ -281,11 +279,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock);
 
 void locks_release_private(struct file_lock *fl)
 {
-	BUG_ON(waitqueue_active(&fl->fl_core.fl_wait));
-	BUG_ON(!list_empty(&fl->fl_core.fl_list));
-	BUG_ON(!list_empty(&fl->fl_core.fl_blocked_requests));
-	BUG_ON(!list_empty(&fl->fl_core.fl_blocked_member));
-	BUG_ON(!hlist_unhashed(&fl->fl_core.fl_link));
+	struct file_lock_core *flc = &fl->fl_core;
+
+	BUG_ON(waitqueue_active(&flc->fl_wait));
+	BUG_ON(!list_empty(&flc->fl_list));
+	BUG_ON(!list_empty(&flc->fl_blocked_requests));
+	BUG_ON(!list_empty(&flc->fl_blocked_member));
+	BUG_ON(!hlist_unhashed(&flc->fl_link));
 
 	if (fl->fl_ops) {
 		if (fl->fl_ops->fl_release_private)
@@ -295,8 +295,8 @@ void locks_release_private(struct file_lock *fl)
 
 	if (fl->fl_lmops) {
 		if (fl->fl_lmops->lm_put_owner) {
-			fl->fl_lmops->lm_put_owner(fl->fl_core.fl_owner);
-			fl->fl_core.fl_owner = NULL;
+			fl->fl_lmops->lm_put_owner(flc->fl_owner);
+			flc->fl_owner = NULL;
 		}
 		fl->fl_lmops = NULL;
 	}
@@ -312,16 +312,15 @@ EXPORT_SYMBOL_GPL(locks_release_private);
  *   %true: @owner has at least one blocker
  *   %false: @owner has no blockers
  */
-bool locks_owner_has_blockers(struct file_lock_context *flctx,
-		fl_owner_t owner)
+bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner)
 {
-	struct file_lock *fl;
+	struct file_lock_core *flc;
 
 	spin_lock(&flctx->flc_lock);
-	list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) {
-		if (fl->fl_core.fl_owner != owner)
+	list_for_each_entry(flc, &flctx->flc_posix, fl_list) {
+		if (flc->fl_owner != owner)
 			continue;
-		if (!list_empty(&fl->fl_core.fl_blocked_requests)) {
+		if (!list_empty(&flc->fl_blocked_requests)) {
 			spin_unlock(&flctx->flc_lock);
 			return true;
 		}

-- 
2.43.0





[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux