Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3503087pxb; Mon, 18 Oct 2021 17:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf3/1s+aEpNapMCeGEh+dJCForax7yeK6e7uprohclddXUPErSWQj5AGQzFs21V3YQxm6P X-Received: by 2002:a50:be87:: with SMTP id b7mr50668872edk.382.1634601886190; Mon, 18 Oct 2021 17:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601886; cv=none; d=google.com; s=arc-20160816; b=KJtltpTION/BsZtf9FbfIyg4y2Ao96B30XhexdtWuCxCHm2rChebKOPJX7sAazSps2 k4jzmS9GBNuD6qb49v3C80t0SpXwngtpCB5VzXsHAz5afMiLeghsvHK1guhceIWX18g3 bDxKtkYXA6p3OMLN2DYYI3PCaPFzS1rRFtniZegkedR/DqLKPO1PuL2sgkxnGIkpZiAu GQ4lXmRLTU1sOb7KpYf0a8aw0c6VY1WHdkxJBjc2uJOcfVkwgmKBFn4wgZ9jshvuh6on WVZmuqUczQ+C8RtVIRu8lF9F2icQZxaUuRxcKd0sEq4CfnBxZ1idk+PYC4d90mb2yVys Sc3g== 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=Vab8t7V9Cvo5wxBdcrQutyS36MhGONzdX/em4VLGtGdsJOZemm8qhJgeR735V4KUPb cXsXgUCcMsS9bu5l3AS+jOANNgHAFThyHxSiIpnf/Sn4ETWMSID7hSAOpm5SoeE891HQ 0nUCBGhGj5O2y3k6QlGi7dIQfrN5PfDEGpZ5WX8W3pBVsVZcsT/QoiZbm5wNVnSj7lDA jLZD1iX8UF1GGbTT77LQVKJtm0dQPMYukBN0lJ3q++MSxtymVTttBYq+NAExIeOecb+i 2c6tV6CJYWnwzcflA67Sm6JuzLCXuRjP6BnRs2MMZk96tr63gSE5DreRYvFrmtErOKVt bkpQ== 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 9si22156717ejf.632.2021.10.18.17.04.23; Mon, 18 Oct 2021 17:04:46 -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 S233951AbhJSAEY (ORCPT + 99 others); Mon, 18 Oct 2021 20:04:24 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40814 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbhJSAEX (ORCPT ); Mon, 18 Oct 2021 20:04:23 -0400 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 3C4241F411B7; Tue, 19 Oct 2021 01:02:09 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v8 14/32] fanotify: Allow file handle encoding for unhashed events Date: Mon, 18 Oct 2021 20:59:57 -0300 Message-Id: <20211019000015.1666608-15-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-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