Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp928123pxj; Fri, 21 May 2021 02:24:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCoMbSK4U3WKCQZrVpcbr0VvzwGdgdKD9B4EyVmgXNZsLTDDTdjvv8cq1KYgerWU16RVeZ X-Received: by 2002:aa7:cac2:: with SMTP id l2mr5958259edt.105.1621589054811; Fri, 21 May 2021 02:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621589054; cv=none; d=google.com; s=arc-20160816; b=rYQ6iZFTacizJQRCg9rh5s0jUa0p8SfheVWa8sHIJSlt9QR/ejU01p1p7HEIiHsNMD x1ChyQ8M8LhL5u35ieiwpQtmbyWj/SdNM0wKwZqWTDkx/5M5reJbmdaJR+KLxXhymHTo wOwUQsP8VRKxYSGS33n/teCFQBmiNHUIfTiizMB89h33hx1voOLXJ+8FtobsL9zrObQY Kl/el3IxJ07zGS/TCapa6HeTc9eWhOzW++ZsDupHJObfSD+6wz/Ohjar1ZHKTplVmEQs +4+2QIapjFUgywCC2b1xvPrju6wRotBwc5eeXkabJHefCwEB+uJrTkk5qKas1FhGvs7V 4big== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ks5WlgQpF2WCjzYJuAPZie3QxR9UXx1ySYon4VqxBkQ=; b=iyH0tqa7Wq+4xCcLcpl0ozySBCpYkefXQmIPWnplILimh2X8EpUXnvODEs38Zbqviu Te36RinxM0uo3NBeAx3rEpH7HBMflFwca7h8v+B7nF+zegAxvMjplr2Ck2H+16+3qjKQ IviQKA1Lx586ovtkRqkLOMbr5aOE2ne7nC2wFWs13bAsS2TF8+uyapMyoXKPFTKNmr8g Yu7xNkGlNmrJY1tzIjDA9atUbe5+weofGC+0xqtkb4zlA44LS/ECPZyiTWB9glrhd0r9 cUGWedohZzDdhRDF/AjU1T83UlGfYFrk8oaQNCsiSZ/Dp7elFGg9zCgth5tni4r9hFZU LOYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si4929723eju.675.2021.05.21.02.23.50; Fri, 21 May 2021 02:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238644AbhEUCnh (ORCPT + 99 others); Thu, 20 May 2021 22:43:37 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54896 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbhEUCng (ORCPT ); Thu, 20 May 2021 22:43:36 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 413EE1F43D57 From: Gabriel Krisman Bertazi To: amir73il@gmail.com Cc: Gabriel Krisman Bertazi , kernel@collabora.com, "Darrick J . Wong" , Theodore Ts'o , Dave Chinner , jack@suse.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 04/11] fanotify: Expose fanotify_mark Date: Thu, 20 May 2021 22:41:27 -0400 Message-Id: <20210521024134.1032503-5-krisman@collabora.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210521024134.1032503-1-krisman@collabora.com> References: <20210521024134.1032503-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org FAN_ERROR will require an error structure to be stored per mark. Therefore, wrap fsnotify_mark in a fanotify specific structure in preparation for that. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 4 +++- fs/notify/fanotify/fanotify.h | 10 ++++++++++ fs/notify/fanotify/fanotify_user.c | 14 +++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 711b36a9483e..34e2ee759b39 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -869,7 +869,9 @@ static void fanotify_freeing_mark(struct fsnotify_mark *mark, static void fanotify_free_mark(struct fsnotify_mark *fsn_mark) { - kmem_cache_free(fanotify_mark_cache, fsn_mark); + struct fanotify_mark *mark = FANOTIFY_MARK(fsn_mark); + + kmem_cache_free(fanotify_mark_cache, mark); } const struct fsnotify_ops fanotify_fsnotify_ops = { diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 4a5e555dc3d2..a399c5e2615d 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -129,6 +129,16 @@ static inline void fanotify_info_copy_name(struct fanotify_info *info, name->name); } +struct fanotify_mark { + struct fsnotify_mark fsn_mark; + struct fanotify_error_event *error_event; +}; + +static inline struct fanotify_mark *FANOTIFY_MARK(struct fsnotify_mark *mark) +{ + return container_of(mark, struct fanotify_mark, fsn_mark); +} + /* * Common structure for fanotify events. Concrete structs are allocated in * fanotify_handle_event() and freed when the information is retrieved by diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 9cc6c8808ed5..00210535a78e 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -914,7 +914,7 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, __kernel_fsid_t *fsid) { struct ucounts *ucounts = group->fanotify_data.ucounts; - struct fsnotify_mark *mark; + struct fanotify_mark *mark; int ret; /* @@ -926,20 +926,20 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, !inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_FANOTIFY_MARKS)) return ERR_PTR(-ENOSPC); - mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL); + mark = kmem_cache_zalloc(fanotify_mark_cache, GFP_KERNEL); if (!mark) { ret = -ENOMEM; goto out_dec_ucounts; } - fsnotify_init_mark(mark, group); - ret = fsnotify_add_mark_locked(mark, connp, type, 0, fsid); + fsnotify_init_mark(&mark->fsn_mark, group); + ret = fsnotify_add_mark_locked(&mark->fsn_mark, connp, type, 0, fsid); if (ret) { - fsnotify_put_mark(mark); + fsnotify_put_mark(&mark->fsn_mark); goto out_dec_ucounts; } - return mark; + return &mark->fsn_mark; out_dec_ucounts: if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS)) @@ -1477,7 +1477,7 @@ static int __init fanotify_user_setup(void) BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 10); BUILD_BUG_ON(HWEIGHT32(FANOTIFY_MARK_FLAGS) != 9); - fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, + fanotify_mark_cache = KMEM_CACHE(fanotify_mark, SLAB_PANIC|SLAB_ACCOUNT); fanotify_fid_event_cachep = KMEM_CACHE(fanotify_fid_event, SLAB_PANIC); -- 2.31.0