Re: [PATCH v5 10/10] fs: add support for copy file range in zonefs
From: Al Viro
Date: Thu Nov 24 2022 - 23:18:47 EST
On Thu, Nov 24, 2022 at 10:47:55AM +0900, Damien Le Moal wrote:
> >> + inode_lock(src_inode);
> >> + inode_lock(dst_inode);
> >
> > So you did zonefs_copy_file_checks() outside of these locks, which mean
> > that everything about the source and destination files may have changed.
> > This does not work.
>
> I forgot to mention that locking 2 inodes blindly like this can leads to
> deadlocks if another process tries a copy range from dst to src at the
> same time (lock order is reversed and so can deadlock).
Not to mention the deadlocks with existing places where fs/namei.c locks
two inodes...