OSDN Git Service

gfs2: Rework the log space allocation logic
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 10 Dec 2020 11:49:56 +0000 (12:49 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 22 Feb 2021 20:16:22 +0000 (21:16 +0100)
commitfe3e397668775e20ad0962459733158838b926af
treeafdd0f6461a394b35a4fa1fcac27eb763ca7d408
parent71b219f4e50b12efffbc8107408e17904f9c47e6
gfs2: Rework the log space allocation logic

The current log space allocation logic is hard to understand or extend.
The principle it that when the log is flushed, we may or may not have a
transaction active that has space allocated in the log.  To deal with
that, we set aside a magical number of blocks to be used in case we
don't have an active transaction.  It isn't clear that the pool will
always be big enough.  In addition, we can't return unused log space at
the end of a transaction, so the number of blocks allocated must exactly
match the number of blocks used.

Simplify this as follows:
 * When transactions are allocated or merged, always reserve enough
   blocks to flush the transaction (err on the safe side).
 * In gfs2_log_flush, return any allocated blocks that haven't been used.
 * Maintain a pool of spare blocks big enough to do one log flush, as
   before.
 * In gfs2_log_flush, when we have no active transaction, allocate a
   suitable number of blocks.  For that, use the spare pool when
   called from logd, and leave the pool alone otherwise.  This means
   that when the log is almost full, logd will still be able to do one
   more log flush, which will result in more log space becoming
   available.

This will make the log space allocator code easier to work with in
the future.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/log.c
fs/gfs2/log.h
fs/gfs2/trans.c