Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp928027pxr; Mon, 11 Apr 2022 10:31:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzRwFpDTPDFpUwPs0wH/9x643NgZ9IcvvipNF3xdZ9gpeIJ1cB7ova7DfPxSumzQAyvhvN X-Received: by 2002:a17:907:6d96:b0:6e8:67da:6c17 with SMTP id sb22-20020a1709076d9600b006e867da6c17mr13087273ejc.258.1649698275304; Mon, 11 Apr 2022 10:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649698275; cv=none; d=google.com; s=arc-20160816; b=Tuv1wYa3soMSOyzef3/U/NtWMdSR9Kq4CuqnfR9VWMz67J7UDmaLmsk0OhL87tbUoM hCe+6H2Zh6NvuW62s9S6LPrJIHEOjsnyDOgZ2C06Eht18BfOOxmGAU+5SqBPaUOKx2ke zAfM6aOdZ7ISBcxAFUeHJZRaLClQbE9/Ia3GoKsE94wJUHHDdx1Q9puLOVgy64JvlMmV /COmJWs6y0tfib/T4BifG1JQyz3wMgjfGxaEnjY692XyKSpBhHX7t9TmwV0n8GALxATB ZiAJiuLjgTkUBZTr7yWhplcFO9clCzsY7fD2jKw5IVWsMG0xKvEjRl1xGE+/oFgTfOs1 fx2Q== 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:references :cc:to:from:subject:user-agent:mime-version:date:message-id; bh=nRuXOhJAGqXJ5D/K+tVytr7557d0uED1nsRzRVCEfIA=; b=g8nLnD8Fqbvkn2buZPJ//mLl1EM1G6Y+0ge3orX18Hi0dsvnvplF47TmFvIwODB+WB +gHU+kp8rriI4lSPBtfs4egl5vOrqq9RAqPvpOe7N28tKOReM3t7AYt/lHuJkt0BLJTI Y8ckbwgiQFOThdDmMoxumsOLYsO3ozC2e7BS64GQrCZSy3HSbbcuH5YLAfYqO9cWiKoe cJCBp1kp0UCqnPUC0YRO46sy33h6/K6ZmytVyeEmLkVLC9q6VnVv5sPp4yi19mxKfI0+ 5lci6GVGH9OT0YEpo/cQwdKA9b41gVsRtbRbIwypjKfCYV6ZhbKBxBHXOH+1G+hzKibJ eZFg== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ed15-20020a056402294f00b0041d89a69ca3si726047edb.326.2022.04.11.10.30.49; Mon, 11 Apr 2022 10:31:15 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347231AbiDKOUI (ORCPT + 99 others); Mon, 11 Apr 2022 10:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347293AbiDKORh (ORCPT ); Mon, 11 Apr 2022 10:17:37 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C16167D0; Mon, 11 Apr 2022 07:15:13 -0700 (PDT) Received: from kwepemi500011.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KcW5q5pJjzFpmJ; Mon, 11 Apr 2022 22:12:47 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by kwepemi500011.china.huawei.com (7.221.188.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Apr 2022 22:15:11 +0800 Received: from [10.174.176.52] (10.174.176.52) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Apr 2022 22:15:10 +0800 Message-ID: <87c0dae7-972a-3c83-dfa6-e1dfab1e1877@huawei.com> Date: Mon, 11 Apr 2022 22:15:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH -next,v2 0/3] nfs: handle writeback errors correctly From: "chenxiaosong (A)" To: , , CC: , , , , References: <20220401034409.256770-1-chenxiaosong2@huawei.com> <3381d7df-7254-e0ba-648c-6e763bda2ea4@huawei.com> In-Reply-To: <3381d7df-7254-e0ba-648c-6e763bda2ea4@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.52] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 ping ... 在 2022/4/1 15:03, chenxiaosong (A) 写道: > 在 2022/4/1 11:44, ChenXiaoSong 写道: >> v1: >> cover letter: (nfs: check writeback errors correctly) >> >> v2: >> - return more nuanced writeback errors in nfs_file_write(). >> - return writeback error in close()->flush() without consumed it. >> - fix: nfs_file_write() will always call nfs_wb_all() even if there is no >> new writeback error. >> >> >> ChenXiaoSong (3): >>    NFS: return more nuanced writeback errors in nfs_file_write() >>    NFS: nfs{,4}_file_flush() return correct writeback errors >>    Revert "nfs: nfs_file_write() should check for writeback errors" >> >>   fs/nfs/file.c     | 23 ++++++++++------------- >>   fs/nfs/nfs4file.c |  8 ++++---- >>   fs/nfs/write.c    |  5 +---- >>   3 files changed, 15 insertions(+), 21 deletions(-) >> > > It is not a good idea to modify error sequence mechanism, as the > `lib/errseq.c` described: > >     22  * Note that there is a risk of collisions if new errors are > being recorded >     23  * frequently, since we have so few bits to use as a counter. >     24  * >     25  * To mitigate this, one bit is used as a flag to tell whether > the value has >     26  * been sampled since a new value was recorded. That allows us > to avoid bumping >     27  * the counter if no one has sampled it since the last time an > error was >     28  * recorded. > > > So, if we want to report nuanced writeback error, it is better to detect > wb error from filemap_check_errors(), and then return > -(file->f_mapping->wb_err & MAX_ERRNO) to userspace without consume it. > >   nfs_mapping_set_error >     mapping_set_error >       __filemap_set_wb_err // record error sequence >         errseq_set >       set_bit(..., &mapping->flags) // record address_space flag > >   // it is not used to be reported, just used to detect >   error = filemap_check_errors // -ENOSPC or -EIO >     test_and_clear_bit(..., &mapping->flags) // error bit cleared > >   // now we try to return nuanced writeback error >   if (error) >   return filemap_check_wb_err(file->f_mapping, 0); >     return -(file->f_mapping->wb_err & MAX_ERRNO) >