> I.e., if one just does "unlink file", then it is not going to be an orphan.
> And most cases are like this. It is rather rare to open a file, unlink it,
> and keep utilizing it.
>
> So my question was - while I'm in ->unlink(), how do I figure out that this
> is not an orphan. So I was thinking about
>
> if (atomic_read(&inode->i_count) == 2)
>
> then this is not an orphan and ->delete_inode() will be called straight
> away (i_nlink is assumed to be 0).
>
> But I've now also figured that ->unlink() may race with write-back, and
> there might be a write-back I/O between ->unlink() (and during it) and
> ->delete_inode(), even though the user-space does not have the file in
> question opened.
>
> So, at the moment, AFAIU
>
> if (atomic_read(&inode->i_count) == 2 && !(inode->i_state & I_DIRTY))
>
> then there won't be any I/O on the inode between ->unlink() and
> ->delete_inode i_nlink is assumed to be 0). Is that right, safe and
> acceptable to use such checks in ->unlink() for optimization?
>
> P.S. the code and short description of the FS I refer is here:
>
http://www.linux-mtd.infradead.org/doc/ubifs.html