From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:36249 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbeDENR1 (ORCPT ); Thu, 5 Apr 2018 09:17:27 -0400 Received: by mail-wm0-f65.google.com with SMTP id x82so7042964wmg.1 for ; Thu, 05 Apr 2018 06:17:26 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Miklos Szeredi , Marko Rauhamaa , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 16/20] fsnotify: generalize fsnotify_detach_connector_from_object() Date: Thu, 5 Apr 2018 16:18:17 +0300 Message-Id: <1522934301-6520-17-git-send-email-amir73il@gmail.com> In-Reply-To: <1522934301-6520-1-git-send-email-amir73il@gmail.com> References: <1522934301-6520-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Use helper fsnotify_connector_obj() helper to reduce object type dependent code. Signed-off-by: Amir Goldstein --- fs/notify/mark.c | 21 ++++++++------------- include/linux/fsnotify_backend.h | 1 + 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 53bacbce1145..3b19ed700ac3 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -177,19 +177,14 @@ static void fsnotify_connector_destroy_workfn(struct work_struct *work) static struct inode *fsnotify_detach_connector_from_object( struct fsnotify_mark_connector *conn) { - struct inode *inode = NULL; - - if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) { - inode = conn->inode; - rcu_assign_pointer(inode->i_fsnotify.marks, NULL); - inode->i_fsnotify.mask = 0; - conn->inode = NULL; - conn->type = FSNOTIFY_OBJ_TYPE_DETACHED; - } else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) { - rcu_assign_pointer(real_mount(conn->mnt)->mnt_fsnotify.marks, - NULL); - real_mount(conn->mnt)->mnt_fsnotify.mask = 0; - conn->mnt = NULL; + struct fsnotify_obj *obj = fsnotify_connector_obj(conn); + struct inode *inode = (conn->type == FSNOTIFY_OBJ_TYPE_INODE) ? + conn->inode : NULL; + + if (obj) { + rcu_assign_pointer(obj->marks, NULL); + obj->mask = 0; + conn->object = NULL; conn->type = FSNOTIFY_OBJ_TYPE_DETACHED; } diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 9a908b96909e..abbd7311077f 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -275,6 +275,7 @@ struct fsnotify_mark_connector { spinlock_t lock; unsigned int type; /* Type of object [lock] */ union { /* Object pointer [lock] */ + void *object; struct inode *inode; struct vfsmount *mnt; }; -- 2.7.4