linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "No space left on device" issue
@ 2022-02-17 19:52 Manish Adkar
  2022-02-17 22:34 ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Manish Adkar @ 2022-02-17 19:52 UTC (permalink / raw)
  To: linux-xfs; +Cc: Erez Zadok, Yifei Liu

Hello,

We have a 16 MB XFS test partition with both plenty of free space
and inodes (419 out of 424), but we’re still getting the error "No
space left on device" when trying to create new files (After the
free space reaches 184320 bytes). It can then only edit and append
any existing files. (There are good reasons why we want to avoid a
larger partition.)

Mount options:

# mount |grep xfs
/dev/ram1 on /mnt/test-xfs type xfs (rw,noatime,attr2,inode64,
logbufs=8,logbsize=32k,noquota)

Here, the filesystem is already mounted with the inode64 option.

Used disk space:

# df /dev/ram1
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/ram1          11500 11320       180  99% /mnt/test-xfs

Used inodes:

# df -i /dev/ram1
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/ram1         424     5   419    2% /mnt/test-xfs

xfs info:

# xfs_info /dev/ram1
meta-data=/dev/ram1      isize=512    agcount=1, agsize=4096 blks
         =               sectsz=4096  attr=2, projid32bit=1
         =               crc=1        finobt=1, sparse=1, rmapbt=0
         =               reflink=1    bigtime=0
data     =               bsize=4096   blocks=4096, imaxpct=25
         =               sunit=0      swidth=0 blks
naming   =version 2      bsize=4096   ascii-ci=0, ftype=1
log      =internal log   bsize=4096   blocks=1221, version=2
         =               sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none           extsz=4096   blocks=0, rtextents=0

In the below “freesp” output, we can see that there are plenty of
contiguous blocks for inode cluster allocation and hence the disk
is not fragmented.

# xfs_db -r -c "freesp -s -a 0" /dev/ram1
   from      to extents  blocks    pct
      1       1       4       4   1.44
      4       7       1       6   2.16
    256     511       1     268  96.40
total free extents 6
total free blocks 278
average free extent size 46.3333

I came across an email thread from the linux-xfs mailing list that
described a similar issue. It mentioned, inodes are allocated in
contiguous chunks of 64. Here, in this case, 1 inode takes 512 bytes
of space and 1 block has 4096 bytes capacity. Hence there would be 8
inodes per block (4096 / 512). Now, to allocate 64 inodes, 8 blocks
would be needed (64 / 8). Looking at the above “freesp” output, we
can see there are 8 contiguous blocks available so the issue must not
be a fragmentation one. But the thread suggests, the allocation has
an alignment requirement, and here, the blocks must be aligned to an
8 block boundary. To look for that,

# xfs_db -r -c "freesp -s -a 0 -A 8" /dev/ram1
   from      to extents  blocks    pct
      1       1       1       1 100.00
total free extents 1
total free blocks 1
average free extent size 1

Here we can see that there is just one single block that is aligned
to the 8 block boundary. Hence, this could be a fragmentation issue.
My concern is that, is my understanding and calculations
(64 / (4096 / 512)) correct about the 8-block boundary? I also tried
this

# xfs_db -r -c "freesp -s -a 0 -A 32" /dev/ram1
   from      to extents  blocks    pct
total free extents 0
total free blocks 0
average free extent size -nan

And this also suggests that there are no such required blocks.

I also saw the suggestion given in this thread to avoid this issue.
It mentions that enabling “sparse” inode allocations will help
resolve this issue. But here “sparse” inode allocation is enabled by
default. So probably there is another resolution to this problem.
Can you help?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: "No space left on device" issue
  2022-02-17 19:52 "No space left on device" issue Manish Adkar
@ 2022-02-17 22:34 ` Dave Chinner
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2022-02-17 22:34 UTC (permalink / raw)
  To: Manish Adkar; +Cc: linux-xfs, Erez Zadok, Yifei Liu

On Thu, Feb 17, 2022 at 11:52:36AM -0800, Manish Adkar wrote:
> Hello,
> 
> We have a 16 MB XFS test partition with both plenty of free space

Single AG filesystems are not a supported configuration.

> and inodes (419 out of 424), but we’re still getting the error "No
> space left on device" when trying to create new files (After the
> free space reaches 184320 bytes).

And there's your problem. Not enough free space for a inode
allocation transaction to guarantee success. Transaction
reservations need to take worst case reservations to guarantee
forwards progress, so if there's not enough space for a worst case
space usage operation, it will fail up front.

> It can then only edit and append
> any existing files. (There are good reasons why we want to avoid a
> larger partition.)

XFS is pretty much the worst choice you could make for this
filesystem.

> In the below “freesp” output, we can see that there are plenty of
> contiguous blocks for inode cluster allocation and hence the disk
> is not fragmented.
> 
> # xfs_db -r -c "freesp -s -a 0" /dev/ram1
>    from      to extents  blocks    pct
>       1       1       4       4   1.44
>       4       7       1       6   2.16
>     256     511       1     268  96.40
> total free extents 6
> total free blocks 278
> average free extent size 46.3333
> 
> I came across an email thread from the linux-xfs mailing list that
> described a similar issue. It mentioned, inodes are allocated in
> contiguous chunks of 64. Here, in this case, 1 inode takes 512 bytes
> of space and 1 block has 4096 bytes capacity. Hence there would be 8
> inodes per block (4096 / 512). Now, to allocate 64 inodes, 8 blocks
> would be needed (64 / 8).

Plus whatever is needed to update the inobt, the finbot, the 2 free
space btrees, the rmap btree and filling the AGFL just to allocate
and track the new inode cluster. THen we also have to take into
account the directory update, too, whihc means we might need to
allocate blocks for the directory data segment, the dir hash btree,i
the dir free space index, all the free space btree, rmap and AGFL
updates that dir block allocation requires, etc.

When we add up the *worst case* space requirement for a file create
operation, it quickly balloons out to be much larger than just the
space an inode cluster consumes.

> Looking at the above “freesp” output, we
> can see there are 8 contiguous blocks available so the issue must not
> be a fragmentation one. But the thread suggests, the allocation has
> an alignment requirement, and here, the blocks must be aligned to an

Your understanding is flawed - large contiguous extents can be cut
down to smaller aligned allocations.

Regardless, there are very good reasons we do not support such tiny
XFS filesystems nor attmept to use every last block available in the
filesystem.

If you truly need a 16MB filesystem for your application, *do not
use XFS*. Use a filesystem that is optimised for tiny devices.

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-17 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 19:52 "No space left on device" issue Manish Adkar
2022-02-17 22:34 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).