From patchwork Fri Apr 20 23:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10353847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41EBB600CC for ; Fri, 20 Apr 2018 23:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31ECC288CD for ; Fri, 20 Apr 2018 23:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26BD9288D9; Fri, 20 Apr 2018 23:10:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFA58288CD for ; Fri, 20 Apr 2018 23:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbeDTXKH (ORCPT ); Fri, 20 Apr 2018 19:10:07 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43628 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbeDTXJy (ORCPT ); Fri, 20 Apr 2018 19:09:54 -0400 Received: by mail-pf0-f194.google.com with SMTP id j11so4898773pff.10 for ; Fri, 20 Apr 2018 16:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aIgHnTymwY1YfKTn836ZzJCvnyNklkMk4hG8/icAjHk=; b=klnjdEhpjIcMqYO9N4PfMb3hOoW2TtZjzC5+D4ZtRln2FSEtCVlyDo6zotrddxAlZ3 KqsVfsc7K/LImxS0iwMjWHsZHd/uUdQ/n+1LnuNQyS4X5vvroZdBu1ogn0AKgqjkqs/Y ue9wazCxmkdX471zOwYA5ou5YGWXEuy6vsWYqkTgzPdRGUmFxsN1zzKZ0RuQ+YpiEsOV SVoYio/oaEV82sxqAo6EFIK/FveLuTOHAQCsXX7KXaMMnWf7/YvUckl+aaO0C64k4tN2 FO72qItgr+gdann6JcV21lZKMtbfdwbVbRzRgtO5yGvrT14jayeu+BcNwUeKVwhaUghS DZaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aIgHnTymwY1YfKTn836ZzJCvnyNklkMk4hG8/icAjHk=; b=NYS7z+fdbuPpqPcYjqgSBr8Ej5jJcAx22vcwwygtwxVvpi+ax7Q4xURuxsF0IeygNI 4cOIV6l7iKZ6475fCybCjCp+eHuQt+jjPGw4HPuUcf/XjOdtSdf1OzKuHUy+vanxLD9l VMXauEkzI1Y9vk8I7Mpat6e1X8KPF+P4kVfUMCXQK2qka/lCTjBykUF5sw+f+X3nhOUm vJB3uMojSVghGM6CyxWU7gTkh54yhet24yA1PwMJSMjW5FQWTEDcnJXRgxQ67eWwXPqP iBOO0Vjs7uboBk30UCbXx2mnfIzY/9ovvPi8oUxqJkNeirxMKCq4u2gu5Xo8zkXvgSd7 54mQ== X-Gm-Message-State: ALQs6tAfIUCFog+WpKbvv348/Dt+4P+4iB+V/Vx8lwzLK2QcYxzyw4oe tNlDq7ECjSFKj5vg0Dw03HU= X-Google-Smtp-Source: AIpwx48Fv6OB8i9BA0VegsABFPctrQ/3KuLlzF6s6vlehFCnl8vJlMKz697eC71zc09YGcZzXktRLA== X-Received: by 10.98.93.153 with SMTP id n25mr2520720pfj.143.1524265793850; Fri, 20 Apr 2018 16:09:53 -0700 (PDT) Received: from amir-VirtualBox.localdomain (c-24-5-85-70.hsd1.ca.comcast.net. [24.5.85.70]) by smtp.gmail.com with ESMTPSA id c12sm10541220pfn.13.2018.04.20.16.09.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Apr 2018 16:09:53 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH v3 11/13] fsnotify: add fsnotify_connector_inode() wrapper Date: Fri, 20 Apr 2018 16:10:59 -0700 Message-Id: <1524265861-6316-12-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524265861-6316-1-git-send-email-amir73il@gmail.com> References: <1524265861-6316-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Soon we will be changing the way to dereference an inode object from connector object. Introduce a wrapper to abstract this dereference. Signed-off-by: Amir Goldstein --- fs/notify/fdinfo.c | 4 ++-- fs/notify/mark.c | 3 ++- include/linux/fsnotify_backend.h | 6 ++++++ kernel/audit_tree.c | 11 ++++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c index 10aac1942c9f..b3cf03e347a8 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c @@ -81,7 +81,7 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) return; inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); - inode = igrab(mark->connector->inode); + inode = igrab(fsnotify_connector_inode(mark->connector)); if (inode) { /* * IN_ALL_EVENTS represents all of the mask bits @@ -117,7 +117,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) mflags |= FAN_MARK_IGNORED_SURV_MODIFY; if (mark->connector->type == FSNOTIFY_OBJ_TYPE_INODE) { - inode = igrab(mark->connector->inode); + inode = igrab(fsnotify_connector_inode(mark->connector)); if (!inode) return; seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ", diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 771178c46eeb..7103a0a442e7 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -140,7 +140,8 @@ void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) __fsnotify_recalc_mask(conn); spin_unlock(&conn->lock); if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) - __fsnotify_update_child_dentry_flags(conn->inode); + __fsnotify_update_child_dentry_flags( + fsnotify_connector_inode(conn)); } /* Free all connectors queued for freeing once SRCU period ends */ diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index b2826dd1e68c..6e9397c16124 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -279,6 +279,12 @@ static inline struct inode *fsnotify_obj_inode(struct fsnotify_obj *obj) return container_of(obj, struct inode, i_fsnotify); } +static inline struct inode *fsnotify_connector_inode( + struct fsnotify_mark_connector *conn) +{ + return conn->inode; +} + /* * A mark is simply an object attached to an in core inode which allows an * fsnotify listener to indicate they are either no longer interested in events diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index eadee98f5a12..529e4757f4e1 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c @@ -183,7 +183,7 @@ static unsigned long chunk_to_key(struct audit_chunk *chunk) */ if (WARN_ON_ONCE(!chunk->mark.connector)) return 0; - return (unsigned long)chunk->mark.connector->inode; + return (unsigned long)fsnotify_connector_inode(chunk->mark.connector); } static inline struct list_head *chunk_hash(unsigned long key) @@ -258,7 +258,7 @@ static void untag_chunk(struct node *p) spin_lock(&entry->lock); /* * mark_mutex protects mark from getting detached and thus also from - * mark->connector->inode getting NULL. + * mark->connector->obj getting NULL. */ if (chunk->dead || !(entry->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) { spin_unlock(&entry->lock); @@ -288,8 +288,9 @@ static void untag_chunk(struct node *p) if (!new) goto Fallback; - if (fsnotify_add_inode_mark_locked(&new->mark, entry->connector->inode, - 1)) { + if (fsnotify_add_inode_mark_locked(&new->mark, + fsnotify_connector_inode(entry->connector), + 1)) { fsnotify_put_mark(&new->mark); goto Fallback; } @@ -434,7 +435,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) } if (fsnotify_add_inode_mark_locked(chunk_entry, - old_entry->connector->inode, 1)) { + fsnotify_connector_inode(old_entry->connector), 1)) { spin_unlock(&old_entry->lock); mutex_unlock(&old_entry->group->mark_mutex); fsnotify_put_mark(chunk_entry);