Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1036674lqp; Thu, 23 May 2024 07:22:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCgtdYUs6rzn0GYdcJxWDPwAAPBcoyaQJZFTOCAK/+DxZkAyUB6vFLKavoNUpLfMC0/UmLo4zZeVm4i847PoGfO2I24yW/JijOYynWPw== X-Google-Smtp-Source: AGHT+IEHrh00GWsjjlTAFArXki4rgSW5N+XiuWpsCxrX4C0vQEecQ9NIo4qA32bjl6+G2/4728Kk X-Received: by 2002:a17:903:41d1:b0:1f3:164a:4b4c with SMTP id d9443c01a7336-1f31c965321mr65146995ad.12.1716474161117; Thu, 23 May 2024 07:22:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716474161; cv=pass; d=google.com; s=arc-20160816; b=lJfa+K/uYxBy6DZj9XOIRZrBjWpQoTGrDmKlJETBhPkUzBJEG8920hdNy9RfAmwwaj 80N9wW/ROxrsdFPfYbuOWmoRsXyQ1YdVvTtrdcLQ0phOXDeKLULq5gvM2P01M+lm8ZfD mvBNFnHVuCRSJKR6lip0suxogAQuKDJHfTLk9Y6r8TI5VwtuV5f15BdUguDcC5JHbUfE qDsFv1I8LG6hn/fx7HA7x91LoyFs3Hy9acoo4CnYz09UmO3HLUxxHHtxTmWywtHb3+2Y tHGL6nd+pKsgDwc8J3fHHMyV1kNle/QeE2JKvCXl3BAgmGpxDu3CVbU6+Ft6nQb6AxCP tJug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=P7HnNkBnQuCqmu8zTIccJJaTZgTQr1fKN1BShJAXcUA=; fh=VvJBipBEabZLyCpPRM9XygDwqTVFQZHqClQWlp0FMM8=; b=z6kSC9XyDGdnDkAMvPhWTw3TceTivIkxuEbKfwEZ+RJXqmxMfuwE0Nn/c9vCAcjuhI TpTf+5PtAYrRW4qF0xc6FGGth8hZbZL5PT/mkFNcMIH0/IHtcSSt18PmkJ5x3Dm/BLR9 /Ja6/lWV5VIjt1Hu/WrV4LYfg+Wsf61OjS720KmjYqRVGhlYOXvKqWO7WmC0Gq8yqD2+ wN4i+WwPY7E7eR6ESlO+F+TzBpxSKA8jTN/M8TKGODiqnhmCAQ1Kmvn8RjT96Z+ifAJB Qhs15VGu4fmTZ+P2yg1VCWVqGP5BPgqwRt9DmGwhX2o4mjfT8AXd/4KTmAUWonlKQarA tfyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=oFTNxQVK; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-187632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f32e31f8cdsi4811145ad.325.2024.05.23.07.22.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 07:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=oFTNxQVK; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-187632-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 74766284EFF for ; Thu, 23 May 2024 14:21:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 823BC14B96E; Thu, 23 May 2024 14:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="oFTNxQVK" Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (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 325F21DFF0; Thu, 23 May 2024 14:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716474094; cv=none; b=Kq0mAuB8h/p5D5O4tU80IH7C/Wp1D9qCfgJdJOod12JiAacnnL5oQY7ao4epuIvdHzwRzh12WWugUuqFkaVcHzuxas0hDRRuCt6/WP0vCQN0Kdn9Ang+qqy0qR15VDOagvt3J3yhg9FspyPS41IQaNPtq+OCGHLNXvQc0iMX5Dk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716474094; c=relaxed/simple; bh=FThYKozjn//4H2MpuuNRgDAHcvOBXsbMlqwA0ybup00=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=B6m+AJMXqjbfYz2A1xb14fS8Ce3uhM6WN1+phfa8LzvIGQE28NaPtdewxThgNjbn0OBEpf3YPWKScC7XmlxxwD72vDCkmuFrdXOTxByykuEnsFnAsR/B4qy8SgGSPJGgf8hF7sUsDyKCNdYuzNOVbQciLRaiopC+aJ8wFijpBZ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=oFTNxQVK; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1716474088; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=P7HnNkBnQuCqmu8zTIccJJaTZgTQr1fKN1BShJAXcUA=; b=oFTNxQVKXbIitYgvQgV4eyRK+sreKUySjtNe67CyaLI+yH5EDpimOIdC0/LommVVFVR9gRXYRyoV4WCpKm0TH7RskaIyEYu1AOFjktlmqP/x43q8AJGFh1yLlIZQ43e8v5TIfPXiROVqEPYqEdv0Dzs8xZ6PwmPj0cf5vh8bWR4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067110;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W739MMQ_1716474086; Received: from 30.39.171.189(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0W739MMQ_1716474086) by smtp.aliyun-inc.com; Thu, 23 May 2024 22:21:27 +0800 Message-ID: <9945b390-3572-4808-b08f-56af9cd3918e@linux.alibaba.com> Date: Thu, 23 May 2024 22:21:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 05/12] cachefiles: remove err_put_fd label in cachefiles_ondemand_daemon_read() To: libaokun@huaweicloud.com, netfs@lists.linux.dev, dhowells@redhat.com, jlayton@kernel.org Cc: hsiangkao@linux.alibaba.com, zhujia.zj@bytedance.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yangerkun@huawei.com, houtao1@huawei.com, yukuai3@huawei.com, wozizhi@huawei.com, Baokun Li References: <20240522114308.2402121-1-libaokun@huaweicloud.com> <20240522114308.2402121-6-libaokun@huaweicloud.com> Content-Language: en-US From: Jingbo Xu In-Reply-To: <20240522114308.2402121-6-libaokun@huaweicloud.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/22/24 7:43 PM, libaokun@huaweicloud.com wrote: > From: Baokun Li > > The err_put_fd label is only used once, so remove it to make the code > more readable. In addition, the logic for deleting error request and > CLOSE request is merged to simplify the code. > > Signed-off-by: Baokun Li > Acked-by: Jeff Layton > Reviewed-by: Jia Zhu > Reviewed-by: Gao Xiang LGTM. Reviewed-by: Jingbo Xu > --- > fs/cachefiles/ondemand.c | 45 ++++++++++++++-------------------------- > 1 file changed, 16 insertions(+), 29 deletions(-) > > diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c > index 3dd002108a87..bb94ef6a6f61 100644 > --- a/fs/cachefiles/ondemand.c > +++ b/fs/cachefiles/ondemand.c > @@ -305,7 +305,6 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, > { > struct cachefiles_req *req; > struct cachefiles_msg *msg; > - unsigned long id = 0; > size_t n; > int ret = 0; > XA_STATE(xas, &cache->reqs, cache->req_id_next); > @@ -340,49 +339,37 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, > cachefiles_grab_object(req->object, cachefiles_obj_get_read_req); > xa_unlock(&cache->reqs); > > - id = xas.xa_index; > - > if (msg->opcode == CACHEFILES_OP_OPEN) { > ret = cachefiles_ondemand_get_fd(req); > if (ret) { > cachefiles_ondemand_set_object_close(req->object); > - goto error; > + goto out; > } > } > > - msg->msg_id = id; > + msg->msg_id = xas.xa_index; > msg->object_id = req->object->ondemand->ondemand_id; > > if (copy_to_user(_buffer, msg, n) != 0) { > ret = -EFAULT; > - goto err_put_fd; > - } > - > - cachefiles_put_object(req->object, cachefiles_obj_put_read_req); > - /* CLOSE request has no reply */ > - if (msg->opcode == CACHEFILES_OP_CLOSE) { > - xa_erase(&cache->reqs, id); > - complete(&req->done); > + if (msg->opcode == CACHEFILES_OP_OPEN) > + close_fd(((struct cachefiles_open *)msg->data)->fd); > } > - > - cachefiles_req_put(req); > - return n; > - > -err_put_fd: > - if (msg->opcode == CACHEFILES_OP_OPEN) > - close_fd(((struct cachefiles_open *)msg->data)->fd); > -error: > +out: > cachefiles_put_object(req->object, cachefiles_obj_put_read_req); > - xas_reset(&xas); > - xas_lock(&xas); > - if (xas_load(&xas) == req) { > - req->error = ret; > - complete(&req->done); > - xas_store(&xas, NULL); > + /* Remove error request and CLOSE request has no reply */ > + if (ret || msg->opcode == CACHEFILES_OP_CLOSE) { > + xas_reset(&xas); > + xas_lock(&xas); > + if (xas_load(&xas) == req) { > + req->error = ret; > + complete(&req->done); > + xas_store(&xas, NULL); > + } > + xas_unlock(&xas); > } > - xas_unlock(&xas); > cachefiles_req_put(req); > - return ret; > + return ret ? ret : n; > } > > typedef int (*init_req_fn)(struct cachefiles_req *req, void *private); -- Thanks, Jingbo