Re: [PATCH v2] loop: use vfs_getattr_nosec() for accurate file size
From: Damien Le Moal
Date: Tue Aug 12 2025 - 01:19:57 EST
On 8/12/25 1:28 PM, Al Viro wrote:
> On Tue, Aug 12, 2025 at 12:42:44PM +0900, Damien Le Moal wrote:
>
>> Since loff_t is "long long", so a signed type, I would keep this interface and
>> add a negative error check in the 2 call sites for get_size(). That is simpler.
>
> Umm... First of all, what's the point of separate get_size() and loop_get_size()?
> Another thing to watch out for - replacing file needs to be careful, lest you
> replace the old file that has come to fail vfs_getattr() with new one that
> does the same thing ;-)
I did a quick grep and missed the fact that get_size() is mostly used through
get_loop_size(). So yes, making these 2 a single function will be clearer.
And indeed, that:
/* size of the new backing store needs to be the same */
if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
goto out_err;
Will need some massaging.
--
Damien Le Moal
Western Digital Research