Re: f2fs: fix to release compress file for F2FS_IOC_RESERVE_COMPRESS_BLOCKS when has no space

From: Yangtao Li
Date: Mon Feb 13 2023 - 09:28:32 EST


> > - if (reserved != cluster_size - compr_blocks)
> > - return -ENOSPC;
> > + if (reserved != cluster_size - compr_blocks) {
> > + dec_valid_block_count(sbi, dn->inode, reserved);
>
> This looks breaking the consistency?

Sorry, I didn't get what you meant. Can you tell me which data is inconsistent.
After executing the F2FS_IOC_RESERVE_COMPRESS_BLOCKS ioctl call,
use the fsck.f2fs tool to check and find no abnormalities.

Chao, any comment?

> > +
> > + for (i = cluster_size - 1; i > 0; i--) {
> > + dn->ofs_in_node--;
> > + blkaddr = f2fs_data_blkaddr(dn);
> > +
> > + if (__is_valid_data_blkaddr(blkaddr)) {
> > + dn->ofs_in_node -= i;
> > + return -ENOSPC;
> > + }
> > +
> > + dn->data_blkaddr = NULL_ADDR;
> > + f2fs_set_data_blkaddr(dn);
> > + }
> > + }

Thx,
Yangtao