Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5060937pxb; Thu, 14 Oct 2021 18:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvGEOCEPbYlIjcO9TQ0gtwGzNS4jAQJp2NtWCGLI46wOHIPNzQ0tAgDOcJGtEOG5TDbA1Z X-Received: by 2002:a17:90a:718c:: with SMTP id i12mr24455550pjk.182.1634260736152; Thu, 14 Oct 2021 18:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634260736; cv=none; d=google.com; s=arc-20160816; b=USVqIhzFCBUqUXcVm4iSMAaeJNJ/ZGWFyYmr8e5PAw2NeEAA1stzBtrRhaPTG+BZMN 322dUwn96v/FxAJJmAJul8I9tU1e9jLtSDvM0wPjxYqSGVwJ5IG3HOE4pY7MBwtECP/3 lkQPwmQxK/Klg5ZgTq33b4ffOnC6xNcqm4FdbSAzaQGNwho00U+JWiLjzu/nU2CLfGTy AJpQKIpLbp4ykZ/TSZqtn0POY9+K0qxOcVVZ2KdkwsAonLJTpF3SmoNgko37DC2iU6l5 oyRW+ZA0jGIpNF69Y0f7Wgqt+1/0r1ZHplXLrpTNlXY5Q9JZ0v64EnKDn7POobHBzTCg bbQQ== 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=HYAYlb585eZH85mwaiwDKCPE0uMnhX2foCjSr/dqtKE=; b=mIveSICdJW6j1Ae4wKVt6e09tfp6yBbl7Le6eBxf8UzCS9+/o6dZXMoSybFKmFYyhe C6sMekAWC1pdELWl5IIRsDBzjzGjxsE9nL0SYyDF9pbgPKj9fBCogwJKLqSYi2iNTlvK V+o2t4LoIWqlSawZx6vWRYFXOUf37tSU5RzoyWrE6ruIhpBuzZuGUmgcorO/fcyy5ytW B9j2eTJUI4noZm8JINc4Af+CycC6+9c2/NEHdAoYIenwcRskzP0yoNWG0sgClNLoZ+BR /vzcqyahhLPUGuXZV6HfR8wGVTEWVeEpjkr8FFyGnr3sb0SVTjqgzvSWjVagZGraYcz4 Fevg== 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 l8si5647441pfd.212.2021.10.14.18.18.43; Thu, 14 Oct 2021 18:18:56 -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 S233686AbhJNVkg (ORCPT + 99 others); Thu, 14 Oct 2021 17:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233658AbhJNVkg (ORCPT ); Thu, 14 Oct 2021 17:40:36 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6BFC061570; Thu, 14 Oct 2021 14:38:30 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 31B891F44F83; Thu, 14 Oct 2021 22:38:28 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v7 13/28] fanotify: Allow file handle encoding for unhashed events Date: Thu, 14 Oct 2021 18:36:31 -0300 Message-Id: <20211014213646.1139469-14-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Allow passing a NULL hash to fanotify_encode_fh and avoid calculating the hash if not needed. Reviewed-by: Jan Kara Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 397ee623ff1e..ec84fee7ad01 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -403,8 +403,12 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, fh->type = type; fh->len = fh_len; - /* Mix fh into event merge key */ - *hash ^= fanotify_hash_fh(fh); + /* + * Mix fh into event merge key. Hash might be NULL in case of + * unhashed FID events (i.e. FAN_FS_ERROR). + */ + if (hash) + *hash ^= fanotify_hash_fh(fh); return FANOTIFY_FH_HDR_LEN + fh_len; -- 2.33.0