linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: adilger.kernel@dilger.ca, ojaswin@linux.ibm.com,
	ritesh.list@gmail.com,
	Harshad Shirwadkar <harshadshirwadkar@gmail.com>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 20/20] ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple
Date: Fri, 17 Mar 2023 11:50:47 -0400	[thread overview]
Message-ID: <20230317155047.GB3270589@mit.edu> (raw)
In-Reply-To: <d88a3d33-6832-2921-c8bb-b935b19e7db4@huaweicloud.com>

On Thu, Mar 16, 2023 at 06:19:40PM +0800, Kemeng Shi wrote:
> Hi Theodore, thanks for feedback. I will submit another patchset for
> mballoc and I would like to include this fix if no one else does. As
> new patches may be conflicted with old ones I submited, I would submit
> the new patchset after the old ones are fully reviewed and applied
> if this fix is not in rush. Thanks!

Hi, I've already taken the your patches into the dev branch; were
there any changes you were intending to make to your patches?

If you could submit a separate fix for the bug that I noticed, that
would be great.

Also, if you are interested in doing some more work in mballoc.c, I
was wondering if you would be interested in adding some Kunit tests
for mballoc.c.  A simple example Kunit test for ext4 can be found in
fs/ext4/inode_test.c.  (The convention is to place tests for foo.c in
foo_test.c.)

[1] https://docs.kernel.org/dev-tools/kunit/

In order to add mballoc Kunit tests, we will need to add some "mock"[2]
functions to simulate what happens when mballoc.c tries reading a
block bitmap.  My thinking was to have a test provide an array of some
data structure like this:

struct test_bitmap {
       unsigned int	start;
       unsigned int	len;
};

[2] https://en.wikipedia.org/wiki/Mock_object

... which indicates the starting block, and the length of a run of
blocks that are marked as in use, where the list of blocks are sorted
by starting block number, and where a starting block of ~0 indicates
the end of the list of block extents.

We would also need have a set of utility ext4 Kunit functions to
create "fake" ext4 superblocks and ext4_sb_info structures.

I was originally thinking that obvious starting Kunit tests would be
for fs/ext4/hash.c and fs/ext4/extents_status.c, since they require
the little or no "mocking" support.  However, there are so many
changes in fs/ext4/mballoc.c, the urgency in having unit tests for it
is getting more urgent --- since if there is a bug in one of these
functions, such as the one that I noted in
ext4_mb_new_blocks_simple(), since it's harder to exhaustively test
some of these smaller sub-functions in integration tests such as those
found in xfstests.  Unit tests are the best way to make sure we're
testing all of the code paths in a complex module such as mballoc.c

Cheers,

						- Ted

  reply	other threads:[~2023-03-17 15:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 17:21 [PATCH v3 00/20] Some bugfix and cleanup to mballoc Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 01/20] ext4: set goal start correctly in ext4_mb_normalize_request Kemeng Shi
2023-03-13  2:07   ` Ritesh Harjani
2023-04-06  5:18   ` [PATCH v3 1/20] " Theodore Ts'o
2023-03-03 17:21 ` [PATCH v3 02/20] ext4: allow to find by goal if EXT4_MB_HINT_GOAL_ONLY is set Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 03/20] ext4: get correct ext4_group_info in ext4_mb_prefetch_fini Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 04/20] ext4: correct calculation of s_mb_preallocated Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 05/20] ext4: correct start of used group pa for debug in ext4_mb_use_group_pa Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 06/20] ext4: protect pa->pa_free in ext4_discard_allocated_blocks Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 07/20] ext4: add missed brelse in ext4_free_blocks_simple Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 08/20] ext4: remove unused return value of ext4_mb_try_best_found and ext4_mb_free_metadata Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 09/20] ext4: Remove unnecessary release when memory allocation failed in ext4_mb_init_cache Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 10/20] ext4: remove unnecessary e4b->bd_buddy_page check in ext4_mb_load_buddy_gfp Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 11/20] ext4: remove unnecessary check in ext4_mb_new_blocks Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 12/20] ext4: remove dead check in mb_buddy_mark_free Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 13/20] ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in ext4_mb_check_limits Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 14/20] ext4: use best found when complex scan of group finishs Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 15/20] ext4: remove unnecessary exit_meta_group_info tag Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 16/20] ext4: remove unnecessary count2 in ext4_free_data_in_buddy Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 17/20] ext4: remove unnecessary goto in ext4_mb_mark_diskspace_used Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 18/20] ext4: remove repeat assignment to ac_f_ex Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 19/20] ext4: remove comment code ext4_discard_preallocations Kemeng Shi
2023-03-03 17:21 ` [PATCH v3 20/20] ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple Kemeng Shi
2023-03-16  5:07   ` Theodore Ts'o
2023-03-16 10:19     ` Kemeng Shi
2023-03-17 15:50       ` Theodore Ts'o [this message]
2023-03-20  7:31         ` Kemeng Shi
2023-03-10  8:17 ` [PATCH v3 00/20] Some bugfix and cleanup to mballoc Kemeng Shi
2023-03-17  1:52 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230317155047.GB3270589@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=harshadshirwadkar@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).