Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1571079lql; Wed, 13 Mar 2024 01:41:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUG7XuurInmrm0VCVDY1CdFWrHja/tO7QSTkIu+yKolSOnDHDoIQFbyNM4QQ1lMra/9EMUSzHD2agrDpncgDKHsBTqNlsNhi056nOuEgg== X-Google-Smtp-Source: AGHT+IHplcc20yUbCqoRrD9D7XaBhyfW3WCzxM08g+vK0B1q9/OBVpUARl7cB7QdF0YhFOlOF5an X-Received: by 2002:a50:8712:0:b0:568:1444:a828 with SMTP id i18-20020a508712000000b005681444a828mr1723389edb.37.1710319315771; Wed, 13 Mar 2024 01:41:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710319315; cv=pass; d=google.com; s=arc-20160816; b=Xx1itxnhnSUKKuI6fKSqAyqqhxEBgYFlvHyfoIxKJqzbto8noZj4hrMylg4gNA2blg GG+Y5nkt2IOP0ewwhBzKww2ay/fthNTf8nwvcZs6/f2ok16bjm6LRx8MCDugCNMmqm5H I3R7HaOFVEy0r0mXu4SbSB1u761xaKxUeRMsKkRPsob+VHjLq+6DcBavhjLWcUQ9ZuIk wW7PsI2YjOp6r+sDwgk2ZFIMktG8Adoj0zbeyYFVkF/JHjKHKF2Hl+2si6pjz8yIAXqQ dzYr7EFjVkgFSxRx9yNoFFkcpGvjD1iaX9jx4UfC0r7/mirY/HchZfdjQGAK/AIFnfnX vuiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=splz9LqGAeewyrIB5UcXZJcELJXLMp1ha+ZaXYwZxgc=; fh=nIP8SQRmPmENrERmvbItxwJ1ZXcGbCSzfAoKPtB+zfU=; b=MUsqW5uMqTRk+NHDlNTvifBaWFQL4H/KexMsNd6CaK+JySPncT4uUvHDQMzaE5ncxZ QVk7H/owBWwo0PjGiAHbGry9/UESNxH8R0axSLH2kvZCgxNbm4DsyPxc9p9zX7UQYSZV kVe7U+aU8vqJVOdYLrkrzxuc9XyeXLBJMSf12+1ZoEQfJnxB5qzqKS1+lOkl55cDYqbK wpA18+w/lz8krKsi7w3IFR6+reHlc209m/tn4QzdcxirYSwa+eCHRdNs5598KjtsM4h9 yLHJmxrTJr6SCK4ankosH+O2gH7A6BG0HjPy1U6bADM4bKqSAjy2OBGtXuiD0OxCylqF aq3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=qK5AAVmH; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-101220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101220-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t15-20020a056402524f00b005688779db47si327189edd.88.2024.03.13.01.41.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 01:41:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=qK5AAVmH; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-101220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101220-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7C4FB1F21F94 for ; Wed, 13 Mar 2024 08:41:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 483AE1B267; Wed, 13 Mar 2024 08:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="qK5AAVmH" Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 2E471387; Wed, 13 Mar 2024 08:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710319305; cv=none; b=p2dF8urDTNbMJ+a2uFKjbDm2wgoUVnFCQqTO9hTQYH7gSPy/xU6jCuWJyQZIqy5rO+2DSQ4K0nJ/ldJ2wOi20r6ria86ltnNDyfD8kbl9h7sM8P+ErrSwuqu7y4+tffOg4dbTWXfBxkyhGBt83bCAE1Kwzov8iH0JjGDppG1ygA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710319305; c=relaxed/simple; bh=MsMasDdN6r+3X0Wz41qXNgAS24bINb5kwJtcRvRsOzw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JzAbmKJTChTSaCn7LcKPwGPnsQ6M6A9vOig6V+U6kfPvp6aU/fZvOIvFRK5XQ8QnR9jN9CHL2dFPn5rRYJIDkHCMtIOhUpR5kJCVspiKa322WDkOZXJvOcn2+on4PmWOOLMp2VLeMpWwO9MZIw/KRUnrrnKYkqM4r1ZABp3Cw8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=qK5AAVmH; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=splz9LqGAeewyrIB5UcXZJcELJXLMp1ha+ZaXYwZxgc=; b=qK5AAVmHGHDC8K+tZUIMJdP3Ko KLA8qiPqLOUd1Vh2/PNVQVhbG6hEOpYDy4JN87XkYtPfpsKbsvt+lpyzMgpbDJe70tEUR+cwO/tCi uQO2v0d05AUZvw8+qb5rGc6x0a55UywGqK5FebcuiNCm47WA8yCYMi7pUHgjykQinbQjOSUhGRRx+ e3ei4eXtcDPS/HB5+L8B8pmNHYM9fIQFxsbhJt7MS8pQRfMTPFGfC4D7XayYk97fRMrdNWvi23GF+ UrXCqAt5C2UCa6Oct/+x9zuP1TCjxuO4X7EMXEd7F/bJOyslG4G/aLZkCVWGzCKTu5ba663LwQSRE FE7vnL3Q==; Received: from [179.93.183.242] (helo=quatroqueijos.cascardo.eti.br) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1rkKB7-009lzb-QX; Wed, 13 Mar 2024 09:41:38 +0100 Date: Wed, 13 Mar 2024 05:41:32 -0300 From: Thadeu Lima de Souza Cascardo To: OGAWA Hirofumi Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gwendal Grignou , dlunev@chromium.org Subject: Re: [PATCH] fat: ignore .. subdir and always add a link to dirs Message-ID: References: <87v86fnz2o.fsf@mail.parknet.co.jp> <87le75s1fg.fsf@mail.parknet.co.jp> <87h6hek50l.fsf@mail.parknet.co.jp> <87cys2jfop.fsf@mail.parknet.co.jp> <878r2mk14a.fsf@mail.parknet.co.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878r2mk14a.fsf@mail.parknet.co.jp> On Wed, Mar 13, 2024 at 05:05:41PM +0900, OGAWA Hirofumi wrote: > Thadeu Lima de Souza Cascardo writes: > > >> You are forgetting to count about normal dirs other than "." and ".."? > >> > > > > Yes, I was not counting those. The patch simply ignores ".." when counting dirs > > (which is used only for determining the number of links), and always adds one > > link. Then, when validating the inode, it also only requires that at least one > > link exists instead of two. > > So you break the mkdir/rmdir link counting, isn't it? > It is off by one on those images with directories without ".." subdir. Otherwise, everything else works fine. mkdir/rmdir inside such directories work without any issues as rmdir that same directory. If, on the other hand, we left everything as is and only skipped the validation, such directories would be created with a link count of 0. Then, doing a mkdir inside them would crash the kernel with a BUG as we cannot increment the link count of an inode with 0 links. So the idea of the fix here is that, independently of the existence of "..", the link count will always be at least 1. Cascardo. > Thanks. > > > There is only one other instance of fat_subdirs being called and that's when > > the root dir link count is determined. I left that one unchanged, as usually > > "." and ".." does not exist there and we always add two links there. > -- > OGAWA Hirofumi