All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfs stats fixes
@ 2018-10-03 12:35 Carlos Maiolino
  2018-10-03 12:35 ` [PATCH 1/2] xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat Carlos Maiolino
  2018-10-03 12:35 ` [PATCH 2/2] xfs: Add new constant to mark start of xqmstat Carlos Maiolino
  0 siblings, 2 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-10-03 12:35 UTC (permalink / raw)
  To: linux-xfs

Hi,

this week I found a bug in the code for xqmstat file in procfs, caused by wrong
offsets while reading the __xfsstats structure fields in xqmstat_proc_show.

This patchset aims to fix the bug (patch 1) and add a way to reduce the
likelyhood of creating the same error again.

xqmstat_proc_show() uses a loop to walk through the quota-specific fields in
__xfsstats when printing the information. The problem is, since the start/end
offsets are hardcoded, any update to __xfsstats may also require an update on
the start offset in xqmstat_proc_show().

I decided to split it into two patches, because I think it is easier to let the
bugfix itself in a separated patch, and the approach on how to avoid it in the
future can be discussed in a separated patch.

My first idea was to try to add a method to check it at compile time, and I spent
some time discussing with Eric what would be the best way to avoid this problem
in the future.
We end up with an possible solution using offsetof() and a new constant in
xfs_stats.h to properly check the offsets at compile time.
Although, after giving it some extra thought, I found it better to only use a
new constant to mark the start of xqmstat in xfs_stats.h and not add any fancy
calculation in xqmstat_proc_show itself.
History told me that all updates to __xfsstats and its respective content/uses,
were properly done when needed, only the xqmstat was left behind because it's
unusual direct usage of the offset markers. So, I believe that the addition of a
new marker to specify the start offset of the quota stat fields is enough to
avoid future problems here, once no more changes will be needed in xqmstat code
whenever __xfsstats requires to be updated.

My idea though is still to move this file to sysfs together with the rest of
statistic code, but by now, I believe we should fix this bug.

Comments?

Cheers.


Carlos Maiolino (2):
  xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat
  xfs: Add new constant to mark start of xqmstat

 fs/xfs/xfs_stats.c | 2 +-
 fs/xfs/xfs_stats.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH 0/2] xfs stats fixes - V2
@ 2018-10-10 12:37 Carlos Maiolino
  2018-10-10 12:37 ` [PATCH 1/2] xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat Carlos Maiolino
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2018-10-10 12:37 UTC (permalink / raw)
  To: linux-xfs

Hi,

this is a new version of my fixes to xfsstats code, the V1 is here:
https://marc.info/?l=linux-xfs&m=153857014823217&w=2

This patchset main goal, is to fix a bug which makes /proc/fs/xfs/xqmstat to
display garbage data (patch 1), and a re-work of the offset marks in __xfsstats,
replacing the defines, by usage of offsetof(), as suggested by Eric and Dave.

Patch 2 isn't tagged as V2, because it's essentially different from the patch 2
of the first version. It still prevents offset mistakes in future updates of
__xfsstats, but in a different way than the V1 patchset

I'm not tagging stable here, because patch 2 only applies cleanly since 4.18


Carlos Maiolino (2):
  xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat
  xfs: use offsetof() in place of offset macros for __xfsstats

 fs/xfs/xfs_stats.c | 52 +++++++++++++++++++++++++---------------------
 fs/xfs/xfs_stats.h | 28 +++----------------------
 2 files changed, 31 insertions(+), 49 deletions(-)

-- 
2.17.1

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

end of thread, other threads:[~2018-10-10 19:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 12:35 [PATCH 0/2] xfs stats fixes Carlos Maiolino
2018-10-03 12:35 ` [PATCH 1/2] xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat Carlos Maiolino
2018-10-03 12:47   ` Eric Sandeen
2018-10-03 13:39     ` Carlos Maiolino
2018-10-03 13:59       ` Eric Sandeen
2018-10-04  8:01         ` Carlos Maiolino
2018-10-03 15:18   ` Darrick J. Wong
2018-10-03 15:20     ` Darrick J. Wong
2018-10-03 12:35 ` [PATCH 2/2] xfs: Add new constant to mark start of xqmstat Carlos Maiolino
2018-10-03 12:51   ` Eric Sandeen
2018-10-03 14:00     ` Carlos Maiolino
2018-10-03 14:04       ` Eric Sandeen
2018-10-03 23:09         ` Dave Chinner
2018-10-10 12:37 [PATCH 0/2] xfs stats fixes - V2 Carlos Maiolino
2018-10-10 12:37 ` [PATCH 1/2] xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat Carlos Maiolino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.