Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1935917pxb; Fri, 5 Mar 2021 03:29:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxf5qVIToZymjKeJeSKE4WnkBxQCQ9001/izfDEWd0L2w3ur5658LUouK8efW1EkYgi5NSg X-Received: by 2002:a17:906:3846:: with SMTP id w6mr1844102ejc.190.1614943790840; Fri, 05 Mar 2021 03:29:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614943790; cv=none; d=google.com; s=arc-20160816; b=mihHoFMfAhew0Bw5Klf4gMUCiFShqTNlDS1xHXkeZ3Id3CnOOGWk1sqrxMOwg3vi6E dILKWeN2jhLMsEmxKkeMAvrr8wswhfAwU5g5yvh03Vq0xn/tGNgXfHAYIJI3YPOMgUTJ eSIpTgt5YV9gFvkycGutkk5yiHX57sD3sZ7RIMhb27VEUc0U602PwkVM8s4nlT4IvQcz qcGHG0E3krD+hNvLhinFa3nESvyTxOgGMsOiUYYbqHjsbnlxPJU9IET+3k8ygXM6LYCg AApghCDXv8ESG7xni3G3EG4X9ZcBryRzQ/O/XrOwAaRY6Yu8F4De74ijlHK3r3BQbGVO djEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:reply-to:in-reply-to:references:mime-version :dkim-signature; bh=9aYdjFgWqnMMd/pegg29j6uoQFfPwGg5bdGoORGW97k=; b=QY9SF+MkFY9+1tN/MXSyhDEi2+zWR4NdjjmnRX6rTH2HmDqYQXPg0z/2EiZMizsNrB JzCI4vkK0cuQPPpdl2RVGCtC2BA5f1tCnxqwHutnOiw4dJn5Rh3EIdgxUJ29ynnIMciZ 74MgLmhOCl9OwDSoTy27kfRcb1TLFkMydZIPpIYvXZjEZrrSUZAMXOHVe8YpkJWzoSr9 VqxOoh4ZEtYrjRWV08t8mpHZgK8tc/YssQMKfHJVQ0lhzkAoKSQ/XFPyTd76VXgiq+O4 3uRyHqDWZ4eoBxmPIjcBllSScElaDN8tkR0IIxa3IU+TX+G2gY2zEmr7Ios8Nw+zJYCz g5Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GB8gzeWV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si1218674eja.212.2021.03.05.03.29.28; Fri, 05 Mar 2021 03:29:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GB8gzeWV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbhCEL23 (ORCPT + 99 others); Fri, 5 Mar 2021 06:28:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhCEL2W (ORCPT ); Fri, 5 Mar 2021 06:28:22 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C04C061574; Fri, 5 Mar 2021 03:28:21 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id a9so1512289qkn.13; Fri, 05 Mar 2021 03:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=9aYdjFgWqnMMd/pegg29j6uoQFfPwGg5bdGoORGW97k=; b=GB8gzeWVGTCxgMSwAIRreiwDrXXiauC4nUTGJm2zsrW++vmdSifqeH6UA3A8sYxw7a qwNzgyRKiRnT7CdsjLl1sdhEDbDbsmR45oAc3W3v9bzzGGeS1RoVE1wZTTdgM3x77Rur Hn4KfV8Ud/cE/rB7e21Hjzs9eC1xlWAV0mZ/+idwqrO/QboY5aKOOLJbO2OHYWRBRt7g oQTotQ6l/CjJzQG6zcjD9YCsU/jdEAXxHokTrRw5x89qX0aVyvwi1WcKNTh57C8Ms3H8 AznwQje+lwNYAc/O8cx1l6Enl768bqB6dczCL2WWxuWVrMzCgUQGB1m9D+TyjNYFWM1Y nC0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=9aYdjFgWqnMMd/pegg29j6uoQFfPwGg5bdGoORGW97k=; b=mpSuH4jwF2AuRzH+sk49+j4nfKC7X+We7I56C1UfqRy+VEGqujdT9yVqmTR+yloQX5 siUZpFutjXdg6RSES1cEtG8fCpmMC1yGtNEJHsxPLZFRXb4qDM87FGJLOzt8Rf/+OFBr ceyPmNWQykfyhPywZsIgVOEtxcNbIvy73exIHHE8ycXhwd6yMwK8fnGR/10qePyUdoLD mmtilRGxm/6RHpOnkqVWcOqxt+pWFGnHX7FSRsp3dcNOxORmk9e5cE3N+BFDkNSHe2Fh wrSE+qxIBHP/MMqMb4OQweAnUV0mdFdD31vfNNrVd9Jiygd2DdT6Cs47dhOfTmycKpr5 soVw== X-Gm-Message-State: AOAM5307iUTNm05pRo+H+XfsPaokotv2/8mUflLMkCpjr5USMt+Rc9I2 rBTrqNCFxL9F07oRJIsW7K2r7dBgUGIkSaYaMuBaMC4nmjgKAw== X-Received: by 2002:a37:ab0f:: with SMTP id u15mr8698366qke.438.1614943701024; Fri, 05 Mar 2021 03:28:21 -0800 (PST) MIME-Version: 1.0 References: <20210305094353.13511-1-baijiaju1990@gmail.com> In-Reply-To: <20210305094353.13511-1-baijiaju1990@gmail.com> Reply-To: fdmanana@gmail.com From: Filipe Manana Date: Fri, 5 Mar 2021 11:28:10 +0000 Message-ID: Subject: Re: [PATCH] fs: btrfs: fix error return code of btrfs_recover_relocation() To: Jia-Ju Bai Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 5, 2021 at 9:46 AM Jia-Ju Bai wrote: > > When the list of reloc_roots is empty, no error return code of > btrfs_recover_relocation() is assigned. > To fix this bug, err is assigned with -ENOENT as error return code. No, there isn't any such bug. If there are no reloc roots, it means there's no relocation to resume, in which case err is already 0 and we therefore return 0. By setting err to -ENOENT, that will cause a mount failure on any fs that does not have relocation to resume. You could have tested this simply by doing: $ mkfs.btrfs -f /dev/sdc $ mount /dev/sdc /mnt/sdc mount: /mnt/sdc: mount(2) system call failed: No such file or directory. It's always a good idea to test patches, even if we are very comfortable with the code they are touching... Thanks. > > Reported-by: TOTE Robot > Signed-off-by: Jia-Ju Bai > --- > fs/btrfs/relocation.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index 232d5da7b7be..631b672a852f 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -3817,8 +3817,10 @@ int btrfs_recover_relocation(struct btrfs_root *ro= ot) > } > btrfs_release_path(path); > > - if (list_empty(&reloc_roots)) > + if (list_empty(&reloc_roots)) { > + err =3D -ENOENT; > goto out; > + } > > rc =3D alloc_reloc_control(fs_info); > if (!rc) { > -- > 2.17.1 > --=20 Filipe David Manana, =E2=80=9CWhether you think you can, or you think you can't =E2=80=94 you're= right.=E2=80=9D