Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3244870lfo; Sun, 22 May 2022 23:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWQu2KQYUDZgHlwWHCluVG6C7Qt4gaBqwT6q+mWYMtCX1JIoUOWKVT5moqxveGT+0zYTQX X-Received: by 2002:a17:902:e945:b0:15f:22cd:c6cc with SMTP id b5-20020a170902e94500b0015f22cdc6ccmr21805724pll.162.1653288178061; Sun, 22 May 2022 23:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653288178; cv=none; d=google.com; s=arc-20160816; b=qLjbNcuhS/2HheEOyhQDuDuHeaAkZwLdnOUMGJa+OveQXrpmO6gK9znsZ9eo8Glfyy Tx697dhxJM6guEJ2NknfzAqtyBYieEOXTErk1wcwtgd8Ioi9cw7497NxYiQ3ezK0GCCi ULJKXxbjEpxS15IdS4GzNWgptPfhmjZ6sm1TH9Mfo3QbK4HP6AEwwlK9LfWna1gJvYZw q3hqEgi/6xMFMjQnLjoFf3+ejcnNf+UtyO1+Se1nGk6rGd0ewB/WUKWdOT3lb6IVLr2U jK31d5ljfTgJ0DLTTSYeujD3T17Dr2ht6S1FL8JsFEnsn9hK/xchhB8Ao0+UUY/5DHmE rKZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from; bh=zr/22CHSv8WHY7FgTxg+sGRgsIxFHxrFGB8thCRARI8=; b=mEWtWvaFVq0WfrylA3iC7kHrC2EfgGWtT1vbAv44aycpnI2ZhKfyMdPad6tJWVFF2i TbsRUM54J2x0h7GK7YorwWHVpwz6yFmb0MEUHYYWnfyB8OxeolfJ0tZw2lXnJjJDnDsH +NRRQX1AG1rMqs1zchMjwhz6eaejXMC4i4OURRTQdyOuKy53GgjCCCjgC3/zg6sCsydL cR4VIogbFIqEIVKwnUawxeMljez9Dy4CnZmKAGrXElDoVE832vmP4AmfXbhgsuTxCAzC r9xXJoBWUb/vqkI68cMPQw0BxJKCIRMbL2rAGCxYekdg/5f//30tTAcJ1k2MnT07BAHE eg+w== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d19-20020a170903209300b00153b2d1646asi8041906plc.114.2022.05.22.23.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:42:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D64C369D9; Sun, 22 May 2022 23:15:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349935AbiEVRmw (ORCPT + 99 others); Sun, 22 May 2022 13:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243789AbiEVRmu (ORCPT ); Sun, 22 May 2022 13:42:50 -0400 Received: from mail.parknet.co.jp (mail.parknet.co.jp [210.171.160.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BB183968A for ; Sun, 22 May 2022 10:42:49 -0700 (PDT) Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 37C9D20012BA; Mon, 23 May 2022 02:42:48 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.16.1/8.16.1/Debian-3) with ESMTPS id 24MHgj7L103712 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 May 2022 02:42:46 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.16.1/8.16.1/Debian-3) with ESMTPS id 24MHgjs7296574 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 May 2022 02:42:45 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.16.1/8.16.1/Submit) id 24MHgiGO296573; Mon, 23 May 2022 02:42:44 +0900 From: OGAWA Hirofumi To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, Colin Walters , Peter Jones , Alexander Larsson , Alberto Ruiz , Christian Kellner , Lennart Poettering , Chung-Chiang Cheng Subject: Re: [RFC PATCH 2/3] fat: add renameat2 RENAME_EXCHANGE flag support References: <20220519092343.2776414-1-javierm@redhat.com> <20220519092343.2776414-3-javierm@redhat.com> Date: Mon, 23 May 2022 02:42:44 +0900 In-Reply-To: <20220519092343.2776414-3-javierm@redhat.com> (Javier Martinez Canillas's message of "Thu, 19 May 2022 11:23:42 +0200") Message-ID: <87fsl1cvl7.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Javier Martinez Canillas writes: > The renameat2 RENAME_EXCHANGE flag allows to atomically exchange two paths > but is currently not supported by the Linux vfat filesystem driver. > > Add a vfat_rename_exchange() helper function that implements this support. > > The super block lock is acquired during the operation to ensure atomicity, > and in the error path actions made are reversed also with the mutex held, > making the whole operation transactional. I'm not fully reviewed yet though (write order and race), basically looks like good. > + /* if directories are not the same, get ".." info to update */ > + if (old_dir != new_dir) { > + if (S_ISDIR(old_inode->i_mode)) > + if (fat_get_dotdot_entry(old_inode, &old_dotdot_bh, &old_dotdot_de)) { > + err = -EIO; > + goto out; > + } > + if (S_ISDIR(new_inode->i_mode)) > + if (fat_get_dotdot_entry(new_inode, &new_dotdot_bh, &new_dotdot_de)) { > + err = -EIO; > + goto out; > + } > + } It may not be linux coding style though, please add {} if () { ... } for non one liner body. > + /* update ".." directory entry info */ > + if (old_dotdot_de) { > + fat_set_start(old_dotdot_de, MSDOS_I(new_dir)->i_logstart); > + mark_buffer_dirty_inode(old_dotdot_bh, old_inode); > + if (IS_DIRSYNC(new_dir)) { > + err = sync_dirty_buffer(old_dotdot_bh); > + if (err) > + goto error_old_dotdot; > + } > + drop_nlink(old_dir); > + inc_nlink(new_dir); > + } > + > + if (new_dotdot_de) { > + fat_set_start(new_dotdot_de, MSDOS_I(old_dir)->i_logstart); > + mark_buffer_dirty_inode(new_dotdot_bh, new_inode); > + if (IS_DIRSYNC(old_dir)) { > + err = sync_dirty_buffer(new_dotdot_bh); > + if (err) > + goto error_new_dotdot; > + } > + drop_nlink(new_dir); > + inc_nlink(old_dir); > + } There are some copy&paste codes, for example above, it may be better to use function and consolidate? If you had some intent, it is ok though. Thanks. -- OGAWA Hirofumi