lkml.org 
[lkml]   [2022]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH 2/3] fat: add renameat2 RENAME_EXCHANGE flag support
Date
Javier Martinez Canillas <javierm@redhat.com> 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 <hirofumi@mail.parknet.co.jp>

\
 
 \ /
  Last update: 2022-05-22 19:44    [W:1.270 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site