From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton Subject: [RFC PATCH 10/12] lockd: convert it to use file_lock_context Date: Wed, 10 Sep 2014 10:28:48 -0400 Message-ID: <1410359330-27564-11-git-send-email-jlayton@primarydata.com> References: <1410359330-27564-1-git-send-email-jlayton@primarydata.com> Cc: linux-kernel@vger.kernel.org, Al Viro , Christoph Hellwig , bfields@fieldses.org To: linux-fsdevel@vger.kernel.org Return-path: Received: from mail-qc0-f177.google.com ([209.85.216.177]:39768 "EHLO mail-qc0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbaIJO3N (ORCPT ); Wed, 10 Sep 2014 10:29:13 -0400 Received: by mail-qc0-f177.google.com with SMTP id i8so18785381qcq.8 for ; Wed, 10 Sep 2014 07:29:12 -0700 (PDT) In-Reply-To: <1410359330-27564-1-git-send-email-jlayton@primarydata.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Signed-off-by: Jeff Layton --- fs/lockd/svcsubs.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index b6f3b84b6e99..93448f5357f0 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -164,12 +164,15 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, { struct inode *inode = nlmsvc_file_inode(file); struct file_lock *fl; + struct file_lock_context *flctx = inode->i_flctx; struct nlm_host *lockhost; + if (!flctx) + return 0; again: file->f_locks = 0; - spin_lock(&inode->i_lock); - for (fl = inode->i_flock; fl; fl = fl->fl_next) { + spin_lock(&flctx->flc_lock); + list_for_each_entry(fl, &flctx->flc_posix, fl_list) { if (fl->fl_lmops != &nlmsvc_lock_operations) continue; @@ -180,7 +183,7 @@ again: if (match(lockhost, host)) { struct file_lock lock = *fl; - spin_unlock(&inode->i_lock); + spin_unlock(&flctx->flc_lock); lock.fl_type = F_UNLCK; lock.fl_start = 0; lock.fl_end = OFFSET_MAX; @@ -192,7 +195,7 @@ again: goto again; } } - spin_unlock(&inode->i_lock); + spin_unlock(&flctx->flc_lock); return 0; } @@ -223,18 +226,21 @@ nlm_file_inuse(struct nlm_file *file) { struct inode *inode = nlmsvc_file_inode(file); struct file_lock *fl; + struct file_lock_context *flctx = inode->i_flctx; if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares) return 1; - spin_lock(&inode->i_lock); - for (fl = inode->i_flock; fl; fl = fl->fl_next) { - if (fl->fl_lmops == &nlmsvc_lock_operations) { - spin_unlock(&inode->i_lock); - return 1; + if (flctx) { + spin_lock(&flctx->flc_lock); + list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + if (fl->fl_lmops == &nlmsvc_lock_operations) { + spin_unlock(&flctx->flc_lock); + return 1; + } } + spin_unlock(&flctx->flc_lock); } - spin_unlock(&inode->i_lock); file->f_locks = 0; return 0; } -- 1.9.3