Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4843397pxb; Mon, 28 Mar 2022 04:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6fMCVW9UALoju0a0YvNhufZzlawm8Wp5nxXKD0aAP7ykY2W/F8kq/atYxx8EHsRn2kGjx X-Received: by 2002:a17:907:2ce3:b0:6df:d80f:ca1 with SMTP id hz3-20020a1709072ce300b006dfd80f0ca1mr27689048ejc.61.1648466833847; Mon, 28 Mar 2022 04:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648466833; cv=none; d=google.com; s=arc-20160816; b=EtEfkMGaKiVgPp8A1NqX/fsiHKiNsPN1HReZwKjc+7I773S9Lfudg7yohN0eVSRXUm fI+qI9119PlSYud71mkyKq4ksgBNdZKqffYO2eaExxpeyL2BwobTowy0Nz7MgZJcNpK3 IT2aDt/zsJO8tPlb94qtEVJNr69lia6Auwkb0VB1sVnkjHiKiYbZjyo/keJDNUcGTISo 6Hx5kCRBl+SJ0bj4B2udnhl9vmDqvv2qnhmQ+/BGCvUqz7vgrLvvgW+BXPObW9GZ1Try +DPXxrJ+D0Uf55t5rRLSjY4HqHuBo0LcxMBjND6aR6/eHcav/G+mz9mFsX08/vGdMUUI UMEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=v7NtkqIrk7Fj2svNguaE4qYUUm4X7PVsavey+NWU4WI=; b=WaxjdJ/OW1NIskAKgLabxPm70wspBRjRJwaIntnNj9tRc5Zs4EI2DRwS+dZBGZSBjk ExSXcV0e4ma5SoDQXI4bkl6Yxcc1BGNz0RQQ5yoK43TulkqzQKvFjlP206Z8q+W8OLEC wOzv6uVf2pmy1wiFU9pEU13VRAULiHoMKO3Q4QmBlBxP4wVJVGiLtL5VQlhn6ZAJ8PW6 RtS/2+4dEg1hnt6Ln+1zoq9N444fPhSczN9Hovpc5QTeWuogjvOkpy3O+BvrXZduYGwl pRVaYzVA5pOB4EiZdmN0lK4rdeGwP17vjbCcWuVB4dig4LaogytHmKhZqfMvDL6d7YBy 7t6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a1709067d4200b006df76385f34si12066706ejp.980.2022.03.28.04.26.48; Mon, 28 Mar 2022 04:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237765AbiC1DNc (ORCPT + 99 others); Sun, 27 Mar 2022 23:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236706AbiC1DN3 (ORCPT ); Sun, 27 Mar 2022 23:13:29 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA83135A97; Sun, 27 Mar 2022 20:11:49 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R731e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V8Kie8j_1648437104; Received: from 30.225.24.93(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V8Kie8j_1648437104) by smtp.aliyun-inc.com(127.0.0.1); Mon, 28 Mar 2022 11:11:46 +0800 Message-ID: Date: Mon, 28 Mar 2022 11:11:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v6 12/22] erofs: add cookie context helper functions Content-Language: en-US To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com, tianzichen@kuaishou.com, fannaihao@baidu.com References: <20220325122223.102958-1-jefflexu@linux.alibaba.com> <20220325122223.102958-13-jefflexu@linux.alibaba.com> From: JeffleXu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/25/22 9:41 PM, Gao Xiang wrote: > Hi Jeffle, > > On Fri, Mar 25, 2022 at 08:22:13PM +0800, Jeffle Xu wrote: >> Introduce "struct erofs_fscache" for managing cookie for backinig file, >> and helper functions for initializing and cleaning up this context >> structure. >> >> Signed-off-by: Jeffle Xu >> --- >> fs/erofs/fscache.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ >> fs/erofs/internal.h | 14 +++++++++++ >> 2 files changed, 75 insertions(+) >> >> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c >> index 08cf570a0810..73235fd43bf6 100644 >> --- a/fs/erofs/fscache.c >> +++ b/fs/erofs/fscache.c >> @@ -7,6 +7,67 @@ >> >> static struct fscache_volume *volume; >> >> +static int erofs_fscache_init_cookie(struct erofs_fscache *ctx, char *path) >> +{ >> + struct fscache_cookie *cookie; >> + >> + cookie = fscache_acquire_cookie(volume, FSCACHE_ADV_WANT_CACHE_SIZE, >> + path, strlen(path), >> + NULL, 0, 0); > > It'd be better to rearrange in one line? Sure. > > path, strlen(path), NULL, 0, 0); > >> + if (!cookie) >> + return -EINVAL; >> + >> + fscache_use_cookie(cookie, false); >> + ctx->cookie = cookie; >> + return 0; >> +} >> + >> +static inline void erofs_fscache_cleanup_cookie(struct erofs_fscache *ctx) >> +{ >> + struct fscache_cookie *cookie = ctx->cookie; >> + >> + fscache_unuse_cookie(cookie, NULL, NULL); >> + fscache_relinquish_cookie(cookie, false); >> + ctx->cookie = NULL; >> +} >> + >> +/* >> + * erofs_fscache_get - create an fscache context for blob file >> + * @sb: superblock >> + * @path: name of blob file >> + * >> + * Return: fscache context on success, ERR_PTR() on failure. >> + */ >> +struct erofs_fscache *erofs_fscache_get(struct super_block *sb, char *path) > > erofs_fscache_register? OK. > >> +{ >> + struct erofs_fscache *ctx; >> + int ret; >> + >> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); >> + if (!ctx) >> + return ERR_PTR(-ENOMEM); >> + >> + ret = erofs_fscache_init_cookie(ctx, path); > > Can we fold it here? No need to introduce such simple wrapper.. > >> + if (ret) { >> + erofs_err(sb, "failed to init cookie"); > > It would be better to print the path? OK. > >> + goto err; > > kfree(ctx); > return ERR_PTR(ret); > > At least for now. Yeah, it's better. > >> + } >> + >> + return ctx; >> +err: >> + kfree(ctx); >> + return ERR_PTR(ret); >> +} >> + >> +void erofs_fscache_put(struct erofs_fscache *ctx) > > erofs_fscache_unregister? OK. > >> +{ >> + if (!ctx) >> + return; >> + >> + erofs_fscache_cleanup_cookie(ctx); > > Fold it too, since such helper doesn't simplify code a lot but need > to take one more time to redirect.. OK. -- Thanks, Jeffle