deepin-kernel/fs/xfs
Darrick J. Wong a6323d0567 xfs: don't over-report free space or inodes in statvfs
[ Upstream commit 4b8d867ca6 ]

Emmanual Florac reports a strange occurrence when project quota limits
are enabled, free space is lower than the remaining quota, and someone
runs statvfs:

  # mkfs.xfs -f /dev/sda
  # mount /dev/sda /mnt -o prjquota
  # xfs_quota  -x -c 'limit -p bhard=2G 55' /mnt
  # mkdir /mnt/dir
  # xfs_io -c 'chproj 55' -c 'chattr +P' -c 'stat -vvvv' /mnt/dir
  # fallocate -l 19g /mnt/a
  # df /mnt /mnt/dir
  Filesystem      Size  Used Avail Use% Mounted on
  /dev/sda         20G   20G  345M  99% /mnt
  /dev/sda        2.0G     0  2.0G   0% /mnt

I think the bug here is that xfs_fill_statvfs_from_dquot unconditionally
assigns to f_bfree without checking that the filesystem has enough free
space to fill the remaining project quota.  However, this is a
longstanding behavior of xfs so it's unclear what to do here.

Cc: <stable@vger.kernel.org> # v2.6.18
Fixes: 932f2c3231 ("[XFS] statvfs component of directory/project quota support, code originally by Glen.")
Reported-by: Emmanuel Florac <eflorac@intellique.com>
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 4534162e0916accc7bfc974a08865bebae0b5c56)
2025-03-14 17:40:52 +08:00
..
libxfs xfs: Reduce unnecessary searches when searching for the best extents 2025-03-14 17:40:52 +08:00
scrub xfs: attr forks require attr, not attr2 2024-12-30 11:01:05 +08:00
Kconfig xfs: verify buffer, inode, and dquot items every tx commit 2024-12-30 11:01:05 +08:00
Makefile xfs: move the realtime summary file scrubber to a separate source file 2023-08-10 07:48:09 -07:00
kmem.c
kmem.h
mrlock.h
xfs.h xfs: verify buffer, inode, and dquot items every tx commit 2024-12-30 11:01:05 +08:00
xfs_acl.c xfs: convert to ctime accessor functions 2023-07-24 10:30:06 +02:00
xfs_acl.h fs: port ->set_acl() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
xfs_aops.c xfs: make xfs_bmapi_convert_delalloc() to allocate the target offset 2024-12-10 20:42:55 +08:00
xfs_aops.h
xfs_attr_inactive.c xfs: make inode unlinked bucket recovery work with quotacheck 2023-09-12 10:31:07 -07:00
xfs_attr_item.c xfs: enforce one namespace per attribute 2024-12-10 20:42:55 +08:00
xfs_attr_item.h
xfs_attr_list.c xfs: enforce one namespace per attribute 2024-12-10 20:42:55 +08:00
xfs_bio_io.c
xfs_bmap_item.c xfs: transfer recovered intent item ownership in ->iop_recover 2024-04-03 15:28:47 +02:00
xfs_bmap_item.h
xfs_bmap_util.c xfs: Fix xfs_prepare_shift() range for RT 2024-12-30 11:01:05 +08:00
xfs_bmap_util.h xfs: fix freeing speculative preallocations for preallocated files 2024-12-10 20:42:55 +08:00
xfs_buf.c xfs: force all buffers to be written during btree bulk load 2024-04-03 15:28:48 +02:00
xfs_buf.h xfs: force all buffers to be written during btree bulk load 2024-04-03 15:28:48 +02:00
xfs_buf_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-30 11:01:05 +08:00
xfs_buf_item.h
xfs_buf_item_recover.c xfs: update the pag for the last AG at recovery time 2025-03-14 17:40:52 +08:00
xfs_dahash_test.c xfs: test the ascii case-insensitive hash 2023-04-11 19:05:05 -07:00
xfs_dahash_test.h xfs: test dir/attr hash when loading module 2023-03-19 09:55:49 -07:00
xfs_dir2_readdir.c
xfs_discard.c xfs: abort fstrim if kernel is suspending 2023-10-04 09:25:04 +11:00
xfs_discard.h xfs: move log discard work to xfs_discard.c 2023-10-04 09:24:02 +11:00
xfs_dquot.c xfs: fix error returns from xfs_bmapi_write 2024-12-10 20:42:54 +08:00
xfs_dquot.h
xfs_dquot_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-30 11:01:05 +08:00
xfs_dquot_item.h
xfs_dquot_item_recover.c xfs: dquot recovery does not validate the recovered dquot 2024-02-16 19:10:46 +01:00
xfs_drain.c xfs: minimize overhead of drain wakeups by using jump labels 2023-04-11 18:59:59 -07:00
xfs_drain.h xfs: minimize overhead of drain wakeups by using jump labels 2023-04-11 18:59:59 -07:00
xfs_error.c xfs: make kobj_type structures constant 2023-02-10 08:59:48 -08:00
xfs_error.h xfs: allow setting full range of panic tags 2023-02-09 18:36:17 -08:00
xfs_export.c xfs: fix reloading entire unlinked bucket lists 2023-09-24 18:12:13 -07:00
xfs_export.h
xfs_extent_busy.c xfs: process free extents to busy list in FIFO order 2023-10-11 12:35:21 -07:00
xfs_extent_busy.h xfs: reduce AGF hold times during fstrim operations 2023-10-04 09:24:52 +11:00
xfs_extfree_item.c xfs: transfer recovered intent item ownership in ->iop_recover 2024-04-03 15:28:47 +02:00
xfs_extfree_item.h
xfs_file.c xfs: create a new helper to return a file's allocation unit 2024-12-30 11:01:05 +08:00
xfs_file.h xfs: create a new helper to return a file's allocation unit 2024-12-30 11:01:05 +08:00
xfs_filestream.c xfs: streamline xfs_filestream_pick_ag 2025-03-14 17:40:52 +08:00
xfs_filestream.h xfs: pass perag to filestreams tracing 2023-02-13 09:14:56 +11:00
xfs_fsmap.c xfs: use XFS_BUF_DADDR_NULL for daddrs in getfsmap code 2024-12-30 11:01:05 +08:00
xfs_fsmap.h
xfs_fsops.c xfs: pass the exact range to initialize to xfs_initialize_perag 2025-03-14 17:40:52 +08:00
xfs_fsops.h
xfs_globals.c xfs: allow setting full range of panic tags 2023-02-09 18:36:17 -08:00
xfs_health.c
xfs_icache.c xfs: don't free cowblocks from under dirty pagecache on unshare 2025-03-14 17:40:52 +08:00
xfs_icache.h xfs: use per-mount cpumask to track nonempty percpu inodegc lists 2023-09-11 08:39:03 -07:00
xfs_icreate_item.c
xfs_icreate_item.h
xfs_inode.c xfs: Check for delayed allocations before setting extsize 2025-03-14 17:40:52 +08:00
xfs_inode.h xfs: Check for delayed allocations before setting extsize 2025-03-14 17:40:52 +08:00
xfs_inode_item.c xfs: verify buffer, inode, and dquot items every tx commit 2024-12-30 11:01:05 +08:00
xfs_inode_item.h xfs: fix AGF vs inode cluster buffer deadlock 2023-06-05 04:08:27 +10:00
xfs_inode_item_recover.c xfs: inode recovery does not validate the recovered inode 2024-02-16 19:10:45 +01:00
xfs_ioctl.c xfs: Check for delayed allocations before setting extsize 2025-03-14 17:40:52 +08:00
xfs_ioctl.h fs: port ->fileattr_set() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
xfs_ioctl32.c fs: port i_{g,u}id_into_vfs{g,u}id() to mnt_idmap 2023-01-19 09:24:29 +01:00
xfs_ioctl32.h
xfs_iomap.c xfs: Propagate errors from xfs_reflink_cancel_cow_range in xfs_dax_write_iomap_end 2025-02-18 11:53:09 +08:00
xfs_iomap.h
xfs_iops.c xfs: declare xfs_file.c symbols in xfs_file.h 2024-12-30 11:01:05 +08:00
xfs_iops.h xfs: declare xfs_file.c symbols in xfs_file.h 2024-12-30 11:01:05 +08:00
xfs_itable.c xfs: fix reloading entire unlinked bucket lists 2023-09-24 18:12:13 -07:00
xfs_itable.h fs: port i_{g,u}id_into_vfs{g,u}id() to mnt_idmap 2023-01-19 09:24:29 +01:00
xfs_iunlink_item.c xfs: create traced helper to get extra perag references 2023-04-11 18:59:55 -07:00
xfs_iunlink_item.h
xfs_iwalk.c xfs: create traced helper to get extra perag references 2023-04-11 18:59:55 -07:00
xfs_iwalk.h
xfs_linux.h xfs: create scaffolding for creating debugfs entries 2023-08-10 07:48:07 -07:00
xfs_log.c xfs: use xfs_defer_pending objects to recover intent items 2024-04-03 15:28:46 +02:00
xfs_log.h xfs: Remove empty declartion in header file 2025-03-14 17:40:52 +08:00
xfs_log_cil.c xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate() 2025-03-14 17:40:52 +08:00
xfs_log_priv.h xfs: use xfs_defer_pending objects to recover intent items 2024-04-03 15:28:46 +02:00
xfs_log_recover.c xfs: update the file system geometry after recoverying superblock buffers 2025-03-14 17:40:52 +08:00
xfs_message.c
xfs_message.h
xfs_mount.c xfs: pass the exact range to initialize to xfs_initialize_perag 2025-03-14 17:40:52 +08:00
xfs_mount.h xfs: make inode unlinked bucket recovery work with quotacheck 2023-09-12 10:31:07 -07:00
xfs_mru_cache.c
xfs_mru_cache.h
xfs_notify_failure.c xfs: correct calculation for agend and blockcount 2023-10-12 10:11:56 +05:30
xfs_ondisk.h xfs: convert flex-array declarations in xfs attr shortform objects 2023-07-17 08:48:56 -07:00
xfs_pnfs.c fs: port ->setattr() to pass mnt_idmap 2023-01-19 09:24:02 +01:00
xfs_pnfs.h
xfs_pwork.c
xfs_pwork.h
xfs_qm.c xfs: fix reloading entire unlinked bucket lists 2023-09-24 18:12:13 -07:00
xfs_qm.h
xfs_qm_bhv.c xfs: don't over-report free space or inodes in statvfs 2025-03-14 17:40:52 +08:00
xfs_qm_syscalls.c
xfs_quota.h
xfs_quotaops.c
xfs_refcount_item.c xfs: transfer recovered intent item ownership in ->iop_recover 2024-04-03 15:28:47 +02:00
xfs_refcount_item.h
xfs_reflink.c xfs: don't free cowblocks from under dirty pagecache on unshare 2025-03-14 17:40:52 +08:00
xfs_reflink.h xfs: don't free cowblocks from under dirty pagecache on unshare 2025-03-14 17:40:52 +08:00
xfs_rmap_item.c xfs: transfer recovered intent item ownership in ->iop_recover 2024-04-03 15:28:47 +02:00
xfs_rmap_item.h
xfs_rtalloc.c xfs: reset rootdir extent size hint after growfsrt 2024-12-30 11:01:05 +08:00
xfs_rtalloc.h xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h 2024-04-03 15:28:46 +02:00
xfs_stats.c
xfs_stats.h
xfs_super.c xfs: report realtime block quota limits on realtime directories 2025-03-14 17:40:52 +08:00
xfs_super.h xfs: create scaffolding for creating debugfs entries 2023-08-10 07:48:07 -07:00
xfs_symlink.c xfs: use consistent uid/gid when grabbing dquots for inodes 2024-12-30 11:01:05 +08:00
xfs_symlink.h fs: port inode_init_owner() to mnt_idmap 2023-01-19 09:24:28 +01:00
xfs_sysctl.c xfs: simplify two-level sysctl registration for xfs_table 2023-04-13 11:49:35 -07:00
xfs_sysctl.h
xfs_sysfs.c xfs: make kobj_type structures constant 2023-02-10 08:59:48 -08:00
xfs_sysfs.h xfs: make kobj_type structures constant 2023-02-10 08:59:48 -08:00
xfs_trace.c
xfs_trace.h xfs: fix finding a last resort AG in xfs_filestream_pick_ag 2024-12-10 20:43:36 +08:00
xfs_trans.c xfs: only run precommits once per transaction object 2024-12-23 21:10:05 +08:00
xfs_trans.h xfs: don't use current->journal_info 2024-12-10 20:26:50 +08:00
xfs_trans_ail.c xfs: don't reverse order of items in bulk AIL insertion 2023-06-29 09:28:23 -07:00
xfs_trans_buf.c
xfs_trans_dquot.c
xfs_trans_priv.h
xfs_xattr.c xfs: require a relatively recent V5 filesystem for LARP mode 2023-09-12 10:31:08 -07:00
xfs_xattr.h