From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 212AEC433F5 for ; Mon, 11 Apr 2022 14:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347150AbiDKOUI (ORCPT ); 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 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) >