Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6606874rdb; Tue, 2 Jan 2024 07:21:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEl8EbPdKkDVazikiWtFWijTSHSnjw3T8k86cW3PLUzIXG8ju0EoAD+7C2HalXB/HsXTUKp X-Received: by 2002:a05:620a:4918:b0:781:a46d:5de6 with SMTP id vy24-20020a05620a491800b00781a46d5de6mr7770582qkn.10.1704208916206; Tue, 02 Jan 2024 07:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704208916; cv=none; d=google.com; s=arc-20160816; b=OE1yEMhKE9fe0CdAdZargw3WnEpvq12YhlZr8Ndx0ltP+oE0DD4+LQXxnVqVUvW+r0 Ddb3ffnGCAEIf5mmr50SomXN+QgJQjzpPARAOkyNlrHcO6lHR4xmcPBxx1gpU+HBePxc /lO1OVwWPxx3h/aMmGY+QOIc6Ru37teqN265Li9N++3iQlwmSrcM49fRBsYdSaLtgSoN hhkqhGPY6YV/U/UAV58xeD3RSINhFUwssfOKZ/6GG1GyxBIJjJLESxlzrSOGnWEM0i3m K8II9gyjact2XYZP8cRcv6oyO2Fwhrq26Q8QDT4osYDAM9xHaXe01yUtk3bAaVU7tJGa el7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :from:organization:dkim-signature; bh=sHnSR+QFwKpo7oWGjVdLyDfof+xSfbIp/ziX7RP5aB4=; fh=t4aTObxHx7IlyGbfV1FqpOLlQUF7nA8IedcEeZI/OuI=; b=POmq/op6DJt/Bn+s+uWsvhTAQVmS8rag3sadtJkJ99NmDjTlZeKVV/OdUSdsopxa+4 Ocn0dffq0uqPm0htAdgaAfp6d9y41q3GrCGmkXLhNsEzw9HLwYAOl5RNpqlnXqc/8Ngk jjbQ79L3D5y6XEB48GI9fpKBvCTa3T2jGb+T6EZs64CcurtgTZCfL65r53ipVi7V91O9 fsEPD9uGc1YxYouh3RPYvvRDyxhRc+7VCZZtBm0PCvwUBihynlq7343ZuaTMgZzFthG6 n1wRObQLOoBoMYjw1FgYQwmSpJPO/mvESvNDzWf974zgnVgWiNabn2pluAk301d47Ses A7Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RAE3Bp/T"; spf=pass (google.com: domain of linux-kernel+bounces-14555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z3-20020a05620a260300b00781b2d6b030si6950074qko.38.2024.01.02.07.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 07:21:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RAE3Bp/T"; spf=pass (google.com: domain of linux-kernel+bounces-14555-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F04611C224E5 for ; Tue, 2 Jan 2024 15:21:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBC471400D; Tue, 2 Jan 2024 15:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RAE3Bp/T" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73F5A14A92 for ; Tue, 2 Jan 2024 15:21:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704208904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sHnSR+QFwKpo7oWGjVdLyDfof+xSfbIp/ziX7RP5aB4=; b=RAE3Bp/TwT/jyrEcWV+C8H7ocSVtRC8f4kFsuUOkNKLHGdB+kd4k7fRqVE7/NPeZCKwefu 7fdXPCtraGP6VEe9s1DncX01mrGUq6uqojxgOtpnIq6tEdIkii9gcSSAvSfA7U9jSQItlo GxuJDsE2dZfO7MpKuyrdABAdrAazL9g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-fpG_uLV2MBefcKkUYRoVag-1; Tue, 02 Jan 2024 10:21:41 -0500 X-MC-Unique: fpG_uLV2MBefcKkUYRoVag-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CDC013C1E9C6; Tue, 2 Jan 2024 15:21:40 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6615492BC6; Tue, 2 Jan 2024 15:21:39 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Jeffrey Altman cc: dhowells@redhat.com, Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] afs: Fix error handling with lookup via FS.InlineBulkStatus Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <140430.1704208899.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 02 Jan 2024 15:21:39 +0000 Message-ID: <140431.1704208899@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 When afs does a lookup, it tries to use FS.InlineBulkStatus to preemptivel= y look up a bunch of files in the parent directory and cache this locally, o= n the basis that we might want to look at them too (for example if someone does an ls on a directory, they may want want to then stat every file listed). FS.InlineBulkStatus can be considered a compound op with the normal abort code applying to the compound as a whole. Each status fetch within the compound is then given its own individual abort code - but assuming no error that prevents the bulk fetch from returning the compound result will be 0, even if all the constituent status fetches failed. At the conclusion of afs_do_lookup(), we should use the abort code from th= e appropriate status to determine the error to return, if any - but instead it is assumed that we were successful if the op as a whole succeeded and w= e return an incompletely initialised inode, resulting in ENOENT, no matter the actual reason. In the particular instance reported, a vnode with no permission granted to be accessed is being given a UAEACCES abort code which should be reported as EACCES, but is instead being reported as ENOENT. Fix this by abandoning the inode (which will be cleaned up with the op) if file[1] has an abort code indicated and turn that abort code into an error instead. Whilst we're at it, add a tracepoint so that the abort codes of the individual subrequests of FS.InlineBulkStatus can be logged. At the momen= t only the container abort code can be 0. Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" conc= ept") Reported-by: Jeffrey Altman Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 12 +++++++++--- include/trace/events/afs.h | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index c14533ef108f..ae563d2a914e 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -708,6 +708,8 @@ static void afs_do_lookup_success(struct afs_operation= *op) break; } = + if (vp->scb.status.abort_code) + trace_afs_bulkstat_error(op, &vp->fid, i, vp->scb.status.abort_code); if (!vp->scb.have_status && !vp->scb.have_error) continue; = @@ -897,12 +899,16 @@ static struct inode *afs_do_lookup(struct inode *dir= , struct dentry *dentry, afs_begin_vnode_operation(op); afs_wait_for_operation(op); } - inode =3D ERR_PTR(afs_op_error(op)); = out_op: if (!afs_op_error(op)) { - inode =3D &op->file[1].vnode->netfs.inode; - op->file[1].vnode =3D NULL; + if (op->file[1].scb.status.abort_code) { + afs_op_accumulate_error(op, -ECONNABORTED, + op->file[1].scb.status.abort_code); + } else { + inode =3D &op->file[1].vnode->netfs.inode; + op->file[1].vnode =3D NULL; + } } = if (op->file[0].scb.have_status) diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h index 5194b7e6dc8d..ce865ea678d3 100644 --- a/include/trace/events/afs.h +++ b/include/trace/events/afs.h @@ -1102,6 +1102,31 @@ TRACE_EVENT(afs_file_error, __print_symbolic(__entry->where, afs_file_errors)) ); = +TRACE_EVENT(afs_bulkstat_error, + TP_PROTO(struct afs_operation *op, struct afs_fid *fid, unsigned int= index, s32 abort), + + TP_ARGS(op, fid, index, abort), + + TP_STRUCT__entry( + __field_struct(struct afs_fid, fid) + __field(unsigned int, op) + __field(unsigned int, index) + __field(s32, abort) + ), + + TP_fast_assign( + __entry->op =3D op->debug_id; + __entry->fid =3D *fid; + __entry->index =3D index; + __entry->abort =3D abort; + ), + + TP_printk("OP=3D%08x[%02x] %llx:%llx:%x a=3D%d", + __entry->op, __entry->index, + __entry->fid.vid, __entry->fid.vnode, __entry->fid.unique, + __entry->abort) + ); + TRACE_EVENT(afs_cm_no_server, TP_PROTO(struct afs_call *call, struct sockaddr_rxrpc *srx), =