* [PATCH] xfs: avoid overflows in i_delayed_blks due to numerous cow reservations
@ 2018-08-02 18:02 Darrick J. Wong
2018-08-02 20:22 ` Eric Sandeen
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2018-08-02 18:02 UTC (permalink / raw)
To: xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Prior to the arrival of copy on write, i_delayed_blks tracked the number
of blocks that had been reserved for delayed allocations. Though the
counter was 32-bits in size, this was enough because writeback would
generally start flushing files well before we hit 2^32 blocks of dirty
data.
However, now that we're using it to track CoW reservations as well, it's
possible to create so many of those reservations that we overflow the
counter. This is kind of an extreme case (it requires ~16T of COW
reservations) but we ought to avoid this trivial overflow. A userspace
visible effect is that stat i_blocks returns incorrect values.
Change the field to xfs_filblks_t, which should suffice to fix the
problem. There already was a 4-byte hole in struct xfs_inode, so we get
this for free.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_inode.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 59b06133ceb8..3fd0e07a363e 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -48,7 +48,7 @@ typedef struct xfs_inode {
spinlock_t i_flags_lock; /* inode i_flags lock */
/* Miscellaneous state. */
unsigned long i_flags; /* see defined flags below */
- unsigned int i_delayed_blks; /* count of delay alloc blks */
+ xfs_filblks_t i_delayed_blks; /* count of delay alloc blks */
struct xfs_icdinode i_d; /* most of ondisk inode */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: avoid overflows in i_delayed_blks due to numerous cow reservations
2018-08-02 18:02 [PATCH] xfs: avoid overflows in i_delayed_blks due to numerous cow reservations Darrick J. Wong
@ 2018-08-02 20:22 ` Eric Sandeen
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2018-08-02 20:22 UTC (permalink / raw)
To: Darrick J. Wong, xfs
On 8/2/18 1:02 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Prior to the arrival of copy on write, i_delayed_blks tracked the number
> of blocks that had been reserved for delayed allocations. Though the
> counter was 32-bits in size, this was enough because writeback would
> generally start flushing files well before we hit 2^32 blocks of dirty
> data.
>
> However, now that we're using it to track CoW reservations as well, it's
> possible to create so many of those reservations that we overflow the
> counter. This is kind of an extreme case (it requires ~16T of COW
> reservations) but we ought to avoid this trivial overflow. A userspace
> visible effect is that stat i_blocks returns incorrect values.
>
> Change the field to xfs_filblks_t, which should suffice to fix the
> problem. There already was a 4-byte hole in struct xfs_inode, so we get
> this for free.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
I think delblks in xfs_qm_vop_chown_reserve() needs to be bumped up
too then, no?
(and, uh, does it then need to be chased through
xfs_trans_reserve_quota_bydquot, xfs_trans_dqresv etc?)
-Eric
> ---
> fs/xfs/xfs_inode.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 59b06133ceb8..3fd0e07a363e 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -48,7 +48,7 @@ typedef struct xfs_inode {
> spinlock_t i_flags_lock; /* inode i_flags lock */
> /* Miscellaneous state. */
> unsigned long i_flags; /* see defined flags below */
> - unsigned int i_delayed_blks; /* count of delay alloc blks */
> + xfs_filblks_t i_delayed_blks; /* count of delay alloc blks */
>
> struct xfs_icdinode i_d; /* most of ondisk inode */
>
> --
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-02 22:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-02 18:02 [PATCH] xfs: avoid overflows in i_delayed_blks due to numerous cow reservations Darrick J. Wong
2018-08-02 20:22 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox