Commit babf0bb9 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs updates from Dave Chinner:
 "This is a big update with lots of new code. The summary below them
  all, so I'll just touch on teh higlights. The two main new features
  are Large Extent Counts and Logged Attribute Replay - these are two
  new foundational features that we are building more complex future
  features on top of.

  For upcoming functionality, we need to be able to store hundreds of
  millions of xattrs per inode. The Large Extent Count feature removes
  the limits that prevent this scale of xattr storage, and while we were
  modifying the on disk extent count format we also increased the number
  of data extents we support per inode from 2^32 to 2^47.

  We also need to be able to modify xattrs as part of larger atomic
  transactions rather than as standalone transactions. The Logged
  Attribute Replay feature introduces the infrastructure that allows us
  to use intents to record the attribute modifications in the journal
  before we start them, hence allowing other atomic transactions to log
  attribute modification intents and then defer the actual modification
  to later. If we then crash, log recovery then guarantees that the
  attribute is replayed in the context of the atomic transaction that
  logged the intent.

  A significant chunk of the commits in this merge are for the base
  attribute replay functionality along with fixes, improvements and
  cleanups related to this new functioanlity. Allison deserves a big
  round of thanks for her ongoing work to get this functionality into
  XFS.

  There are also many other smaller changes and improvements, so overall
  this is one of the bigger XFS merge requests in some time.

  I will be following up next week with another smaller pull request -
  we already have another round of fixes and improvements to the logged
  attribute replay functionality just about ready to go. They'll soak
  and test over the next week, and I'll send a pull request for them
  near the end of the merge window.

  Summary:

   - support for printk message indexing.

   - large extent counts to provide support for up to 2^47 data extents
     and 2^32 attribute extents, allowing us to scale beyond 4 billion
     data extents to billions of xattrs per inode.

   - conversion of various flags fields to be consistently declared as
     unsigned bit fields.

   - improvements to realtime extent accounting and converts them to
     per-cpu counters to match all the other block and inode accounting.

   - reworks core log formatting code to reduce iterations, have a
     shorter, cleaner fast path and generally be easier to understand
     and maintain.

   - improvements to rmap btree searches that reduce overhead by up to
     30% resulting in xfs_scrub runtime reductions of 15%.

   - improvements to reflink that remove the size limitations in
     remapping operations and greatly reduce the size of transaction
     reservations.

   - reworks the minimum log size calculations to allow us to change
     transaction reservations without changing the minimum supported log
     size.

   - removal of quota warning support as it has never been used on
     Linux.

   - intent whiteouts to allow us to cancel intents that are completed
     entirely in memory rather than having use CPU and disk bandwidth
     formatting and writing them into the journal when it is not
     necessary. This makes rmap, reflink and extent freeing slightly
     more efficient, but provides massive improvements for....

   - Logged Attribute Replay feature support. This is a fundamental
     change to the way we modify attributes, laying the foundation for
     future integration of attribute modifications as part of other
     atomic transactional operations the filesystem performs.

   - Lots of cleanups and fixes for the logged attribute replay
     functionality"

* tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (124 commits)
  xfs: can't use kmem_zalloc() for attribute buffers
  xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify
  xfs: ATTR_REPLACE algorithm with LARP enabled needs rework
  xfs: use XFS_DA_OP flags in deferred attr ops
  xfs: remove xfs_attri_remove_iter
  xfs: switch attr remove to xfs_attri_set_iter
  xfs: introduce attr remove initial states into xfs_attr_set_iter
  xfs: xfs_attr_set_iter() does not need to return EAGAIN
  xfs: clean up final attr removal in xfs_attr_set_iter
  xfs: remote xattr removal in xfs_attr_set_iter() is conditional
  xfs: XFS_DAS_LEAF_REPLACE state only needed if !LARP
  xfs: split remote attr setting out from replace path
  xfs: consolidate leaf/node states in xfs_attr_set_iter
  xfs: kill XFS_DAC_LEAF_ADDNAME_INIT
  xfs: separate out initial attr_set states
  xfs: don't set quota warning values
  xfs: remove warning counters from struct xfs_dquot_res
  xfs: remove quota warning limit from struct xfs_quota_limits
  xfs: rework deferred attribute operation setup
  xfs: make xattri_leaf_bp more useful
  ...
parents e375780b efd409a4
...@@ -102,6 +102,7 @@ xfs-y += xfs_log.o \ ...@@ -102,6 +102,7 @@ xfs-y += xfs_log.o \
xfs_buf_item_recover.o \ xfs_buf_item_recover.o \
xfs_dquot_item_recover.o \ xfs_dquot_item_recover.o \
xfs_extfree_item.o \ xfs_extfree_item.o \
xfs_attr_item.o \
xfs_icreate_item.o \ xfs_icreate_item.o \
xfs_inode_item.o \ xfs_inode_item.o \
xfs_inode_item_recover.o \ xfs_inode_item_recover.o \
......
...@@ -2511,7 +2511,7 @@ __xfs_free_extent_later( ...@@ -2511,7 +2511,7 @@ __xfs_free_extent_later(
ASSERT(bno != NULLFSBLOCK); ASSERT(bno != NULLFSBLOCK);
ASSERT(len > 0); ASSERT(len > 0);
ASSERT(len <= MAXEXTLEN); ASSERT(len <= XFS_MAX_BMBT_EXTLEN);
ASSERT(!isnullstartblock(bno)); ASSERT(!isnullstartblock(bno));
agno = XFS_FSB_TO_AGNO(mp, bno); agno = XFS_FSB_TO_AGNO(mp, bno);
agbno = XFS_FSB_TO_AGBNO(mp, bno); agbno = XFS_FSB_TO_AGBNO(mp, bno);
...@@ -2777,7 +2777,7 @@ xfs_alloc_get_freelist( ...@@ -2777,7 +2777,7 @@ xfs_alloc_get_freelist(
xfs_agblock_t bno; xfs_agblock_t bno;
__be32 *agfl_bno; __be32 *agfl_bno;
int error; int error;
int logflags; uint32_t logflags;
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_perag *pag; struct xfs_perag *pag;
...@@ -2830,9 +2830,9 @@ xfs_alloc_get_freelist( ...@@ -2830,9 +2830,9 @@ xfs_alloc_get_freelist(
*/ */
void void
xfs_alloc_log_agf( xfs_alloc_log_agf(
xfs_trans_t *tp, /* transaction pointer */ struct xfs_trans *tp,
struct xfs_buf *bp, /* buffer for a.g. freelist header */ struct xfs_buf *bp,
int fields) /* mask of fields to be logged (XFS_AGF_...) */ uint32_t fields)
{ {
int first; /* first byte offset */ int first; /* first byte offset */
int last; /* last byte offset */ int last; /* last byte offset */
...@@ -2902,7 +2902,7 @@ xfs_alloc_put_freelist( ...@@ -2902,7 +2902,7 @@ xfs_alloc_put_freelist(
struct xfs_perag *pag; struct xfs_perag *pag;
__be32 *blockp; __be32 *blockp;
int error; int error;
int logflags; uint32_t logflags;
__be32 *agfl_bno; __be32 *agfl_bno;
int startoff; int startoff;
......
...@@ -121,7 +121,7 @@ void ...@@ -121,7 +121,7 @@ void
xfs_alloc_log_agf( xfs_alloc_log_agf(
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
struct xfs_buf *bp, /* buffer for a.g. freelist header */ struct xfs_buf *bp, /* buffer for a.g. freelist header */
int fields);/* mask of fields to be logged (XFS_AGF_...) */ uint32_t fields);/* mask of fields to be logged (XFS_AGF_...) */
/* /*
* Interface for inode allocation to force the pag data to be initialized. * Interface for inode allocation to force the pag data to be initialized.
......
This diff is collapsed.
...@@ -28,6 +28,15 @@ struct xfs_attr_list_context; ...@@ -28,6 +28,15 @@ struct xfs_attr_list_context;
*/ */
#define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */
static inline bool xfs_has_larp(struct xfs_mount *mp)
{
#ifdef DEBUG
return xfs_globals.larp;
#else
return false;
#endif
}
/* /*
* Kernel-internal version of the attrlist cursor. * Kernel-internal version of the attrlist cursor.
*/ */
...@@ -425,7 +434,7 @@ struct xfs_attr_list_context { ...@@ -425,7 +434,7 @@ struct xfs_attr_list_context {
*/ */
/* /*
* Enum values for xfs_delattr_context.da_state * Enum values for xfs_attr_item.xattri_da_state
* *
* These values are used by delayed attribute operations to keep track of where * These values are used by delayed attribute operations to keep track of where
* they were before they returned -EAGAIN. A return code of -EAGAIN signals the * they were before they returned -EAGAIN. A return code of -EAGAIN signals the
...@@ -434,46 +443,105 @@ struct xfs_attr_list_context { ...@@ -434,46 +443,105 @@ struct xfs_attr_list_context {
* to where it was and resume executing where it left off. * to where it was and resume executing where it left off.
*/ */
enum xfs_delattr_state { enum xfs_delattr_state {
XFS_DAS_UNINIT = 0, /* No state has been set yet */ XFS_DAS_UNINIT = 0, /* No state has been set yet */
XFS_DAS_RMTBLK, /* Removing remote blks */
XFS_DAS_RM_NAME, /* Remove attr name */ /*
XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ * Initial sequence states. The replace setup code relies on the
XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ * ADD and REMOVE states for a specific format to be sequential so
XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ * that we can transform the initial operation to be performed
XFS_DAS_FLIP_LFLAG, /* Flipped leaf INCOMPLETE attr flag */ * according to the xfs_has_larp() state easily.
XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */ */
XFS_DAS_RD_LEAF, /* Read in the new leaf */ XFS_DAS_SF_ADD, /* Initial sf add state */
XFS_DAS_ALLOC_NODE, /* We are allocating node blocks */ XFS_DAS_SF_REMOVE, /* Initial sf replace/remove state */
XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */
XFS_DAS_RM_NBLK, /* A rename is removing node blocks */ XFS_DAS_LEAF_ADD, /* Initial leaf add state */
XFS_DAS_CLR_FLAG, /* Clear incomplete flag */ XFS_DAS_LEAF_REMOVE, /* Initial leaf replace/remove state */
XFS_DAS_NODE_ADD, /* Initial node add state */
XFS_DAS_NODE_REMOVE, /* Initial node replace/remove state */
/* Leaf state set/replace/remove sequence */
XFS_DAS_LEAF_SET_RMT, /* set a remote xattr from a leaf */
XFS_DAS_LEAF_ALLOC_RMT, /* We are allocating remote blocks */
XFS_DAS_LEAF_REPLACE, /* Perform replace ops on a leaf */
XFS_DAS_LEAF_REMOVE_OLD, /* Start removing old attr from leaf */
XFS_DAS_LEAF_REMOVE_RMT, /* A rename is removing remote blocks */
XFS_DAS_LEAF_REMOVE_ATTR, /* Remove the old attr from a leaf */
/* Node state sequence, must match leaf state above */
XFS_DAS_NODE_SET_RMT, /* set a remote xattr from a node */
XFS_DAS_NODE_ALLOC_RMT, /* We are allocating remote blocks */
XFS_DAS_NODE_REPLACE, /* Perform replace ops on a node */
XFS_DAS_NODE_REMOVE_OLD, /* Start removing old attr from node */
XFS_DAS_NODE_REMOVE_RMT, /* A rename is removing remote blocks */
XFS_DAS_NODE_REMOVE_ATTR, /* Remove the old attr from a node */
XFS_DAS_DONE, /* finished operation */
}; };
#define XFS_DAS_STRINGS \
{ XFS_DAS_UNINIT, "XFS_DAS_UNINIT" }, \
{ XFS_DAS_SF_ADD, "XFS_DAS_SF_ADD" }, \
{ XFS_DAS_SF_REMOVE, "XFS_DAS_SF_REMOVE" }, \
{ XFS_DAS_LEAF_ADD, "XFS_DAS_LEAF_ADD" }, \
{ XFS_DAS_LEAF_REMOVE, "XFS_DAS_LEAF_REMOVE" }, \
{ XFS_DAS_NODE_ADD, "XFS_DAS_NODE_ADD" }, \
{ XFS_DAS_NODE_REMOVE, "XFS_DAS_NODE_REMOVE" }, \
{ XFS_DAS_LEAF_SET_RMT, "XFS_DAS_LEAF_SET_RMT" }, \
{ XFS_DAS_LEAF_ALLOC_RMT, "XFS_DAS_LEAF_ALLOC_RMT" }, \
{ XFS_DAS_LEAF_REPLACE, "XFS_DAS_LEAF_REPLACE" }, \
{ XFS_DAS_LEAF_REMOVE_OLD, "XFS_DAS_LEAF_REMOVE_OLD" }, \
{ XFS_DAS_LEAF_REMOVE_RMT, "XFS_DAS_LEAF_REMOVE_RMT" }, \
{ XFS_DAS_LEAF_REMOVE_ATTR, "XFS_DAS_LEAF_REMOVE_ATTR" }, \
{ XFS_DAS_NODE_SET_RMT, "XFS_DAS_NODE_SET_RMT" }, \
{ XFS_DAS_NODE_ALLOC_RMT, "XFS_DAS_NODE_ALLOC_RMT" }, \
{ XFS_DAS_NODE_REPLACE, "XFS_DAS_NODE_REPLACE" }, \
{ XFS_DAS_NODE_REMOVE_OLD, "XFS_DAS_NODE_REMOVE_OLD" }, \
{ XFS_DAS_NODE_REMOVE_RMT, "XFS_DAS_NODE_REMOVE_RMT" }, \
{ XFS_DAS_NODE_REMOVE_ATTR, "XFS_DAS_NODE_REMOVE_ATTR" }, \
{ XFS_DAS_DONE, "XFS_DAS_DONE" }
/* /*
* Defines for xfs_delattr_context.flags * Defines for xfs_attr_item.xattri_flags
*/ */
#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/
#define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/
/* /*
* Context used for keeping track of delayed attribute operations * Context used for keeping track of delayed attribute operations
*/ */
struct xfs_delattr_context { struct xfs_attr_item {
struct xfs_da_args *da_args; struct xfs_da_args *xattri_da_args;
/*
* Used by xfs_attr_set to hold a leaf buffer across a transaction roll
*/
struct xfs_buf *xattri_leaf_bp;
/* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */
struct xfs_bmbt_irec map; struct xfs_bmbt_irec xattri_map;
xfs_dablk_t lblkno; xfs_dablk_t xattri_lblkno;
int blkcnt; int xattri_blkcnt;
/* Used in xfs_attr_node_removename to roll through removing blocks */ /* Used in xfs_attr_node_removename to roll through removing blocks */
struct xfs_da_state *da_state; struct xfs_da_state *xattri_da_state;
/* Used to keep track of current state of delayed operation */ /* Used to keep track of current state of delayed operation */
unsigned int flags; unsigned int xattri_flags;
enum xfs_delattr_state dela_state; enum xfs_delattr_state xattri_dela_state;
/*
* Attr operation being performed - XFS_ATTR_OP_FLAGS_*
*/
unsigned int xattri_op_flags;
/*
* used to log this item to an intent containing a list of attrs to
* commit later
*/
struct list_head xattri_list;
}; };
/*======================================================================== /*========================================================================
* Function prototypes for the kernel. * Function prototypes for the kernel.
*========================================================================*/ *========================================================================*/
...@@ -489,11 +557,81 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); ...@@ -489,11 +557,81 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip);
int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get_ilocked(struct xfs_da_args *args);
int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args);
int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args);
int xfs_attr_set_args(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_item *attr);
int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_attr_item *attr);
int xfs_attr_remove_iter(struct xfs_delattr_context *dac);
bool xfs_attr_namecheck(const void *name, size_t length); bool xfs_attr_namecheck(const void *name, size_t length);
void xfs_delattr_context_init(struct xfs_delattr_context *dac, int xfs_attr_calc_size(struct xfs_da_args *args, int *local);
struct xfs_da_args *args); void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres,
unsigned int *total);
extern struct kmem_cache *xfs_attri_cache;
extern struct kmem_cache *xfs_attrd_cache;
int __init xfs_attri_init_cache(void);
void xfs_attri_destroy_cache(void);
int __init xfs_attrd_init_cache(void);
void xfs_attrd_destroy_cache(void);
/*
* Check to see if the attr should be upgraded from non-existent or shortform to
* single-leaf-block attribute list.
*/
static inline bool
xfs_attr_is_shortform(
struct xfs_inode *ip)
{
return ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL ||
(ip->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
ip->i_afp->if_nextents == 0);
}
static inline enum xfs_delattr_state
xfs_attr_init_add_state(struct xfs_da_args *args)
{
/*
* When called from the completion of a attr remove to determine the
* next state, the attribute fork may be null. This can occur only occur
* on a pure remove, but we grab the next state before we check if a
* replace operation is being performed. If we are called from any other
* context, i_afp is guaranteed to exist. Hence if the attr fork is
* null, we were called from a pure remove operation and so we are done.
*/
if (!args->dp->i_afp)
return XFS_DAS_DONE;
args->op_flags |= XFS_DA_OP_ADDNAME;
if (xfs_attr_is_shortform(args->dp))
return XFS_DAS_SF_ADD;
if (xfs_attr_is_leaf(args->dp))
return XFS_DAS_LEAF_ADD;
return XFS_DAS_NODE_ADD;
}
static inline enum xfs_delattr_state
xfs_attr_init_remove_state(struct xfs_da_args *args)
{
args->op_flags |= XFS_DA_OP_REMOVE;
if (xfs_attr_is_shortform(args->dp))
return XFS_DAS_SF_REMOVE;
if (xfs_attr_is_leaf(args->dp))
return XFS_DAS_LEAF_REMOVE;
return XFS_DAS_NODE_REMOVE;
}
/*
* If we are logging the attributes, then we have to start with removal of the
* old attribute so that there is always consistent state that we can recover
* from if the system goes down part way through. We always log the new attr
* value, so even when we remove the attr first we still have the information in
* the log to finish the replace operation atomically.
*/
static inline enum xfs_delattr_state
xfs_attr_init_replace_state(struct xfs_da_args *args)
{
args->op_flags |= XFS_DA_OP_ADDNAME | XFS_DA_OP_REPLACE;
if (xfs_has_larp(args->dp->i_mount))
return xfs_attr_init_remove_state(args);
return xfs_attr_init_add_state(args);
}
#endif /* __XFS_ATTR_H__ */ #endif /* __XFS_ATTR_H__ */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_errortag.h"
/* /*
...@@ -309,6 +310,15 @@ xfs_attr3_leaf_verify( ...@@ -309,6 +310,15 @@ xfs_attr3_leaf_verify(
if (fa) if (fa)
return fa; return fa;
/*
* Empty leaf blocks should never occur; they imply the existence of a
* software bug that needs fixing. xfs_repair also flags them as a
* corruption that needs fixing, so we should never let these go to
* disk.
*/
if (ichdr.count == 0)
return __this_address;
/* /*
* firstused is the block offset of the first name info structure. * firstused is the block offset of the first name info structure.
* Make sure it doesn't go off the block or crash into the header. * Make sure it doesn't go off the block or crash into the header.
...@@ -445,6 +455,14 @@ xfs_attr3_leaf_read( ...@@ -445,6 +455,14 @@ xfs_attr3_leaf_read(
* Namespace helper routines * Namespace helper routines
*========================================================================*/ *========================================================================*/
/*
* If we are in log recovery, then we want the lookup to ignore the INCOMPLETE
* flag on disk - if there's an incomplete attr then recovery needs to tear it
* down. If there's no incomplete attr, then recovery needs to tear that attr
* down to replace it with the attr that has been logged. In this case, the
* INCOMPLETE flag will not be set in attr->attr_filter, but rather
* XFS_DA_OP_RECOVERY will be set in args->op_flags.
*/
static bool static bool
xfs_attr_match( xfs_attr_match(
struct xfs_da_args *args, struct xfs_da_args *args,
...@@ -452,14 +470,18 @@ xfs_attr_match( ...@@ -452,14 +470,18 @@ xfs_attr_match(
unsigned char *name, unsigned char *name,
int flags) int flags)
{ {
if (args->namelen != namelen) if (args->namelen != namelen)
return false; return false;
if (memcmp(args->name, name, namelen) != 0) if (memcmp(args->name, name, namelen) != 0)
return false; return false;
/*
* If we are looking for incomplete entries, show only those, else only /* Recovery ignores the INCOMPLETE flag. */
* show complete entries. if ((args->op_flags & XFS_DA_OP_RECOVERY) &&
*/ args->attr_filter == (flags & XFS_ATTR_NSP_ONDISK_MASK))
return true;
/* All remaining matches need to be filtered by INCOMPLETE state. */
if (args->attr_filter != if (args->attr_filter !=
(flags & (XFS_ATTR_NSP_ONDISK_MASK | XFS_ATTR_INCOMPLETE))) (flags & (XFS_ATTR_NSP_ONDISK_MASK | XFS_ATTR_INCOMPLETE)))
return false; return false;
...@@ -798,6 +820,14 @@ xfs_attr_sf_removename( ...@@ -798,6 +820,14 @@ xfs_attr_sf_removename(
sf = (struct xfs_attr_shortform *)dp->i_afp->if_u1.if_data; sf = (struct xfs_attr_shortform *)dp->i_afp->if_u1.if_data;
error = xfs_attr_sf_findname(args, &sfe, &base); error = xfs_attr_sf_findname(args, &sfe, &base);
/*
* If we are recovering an operation, finding nothing to
* remove is not an error - it just means there was nothing
* to clean up.
*/
if (error == -ENOATTR && (args->op_flags & XFS_DA_OP_RECOVERY))
return 0;
if (error != -EEXIST) if (error != -EEXIST)
return error; return error;
size = xfs_attr_sf_entsize(sfe); size = xfs_attr_sf_entsize(sfe);
...@@ -818,7 +848,7 @@ xfs_attr_sf_removename( ...@@ -818,7 +848,7 @@ xfs_attr_sf_removename(
totsize -= size; totsize -= size;
if (totsize == sizeof(xfs_attr_sf_hdr_t) && xfs_has_attr2(mp) && if (totsize == sizeof(xfs_attr_sf_hdr_t) && xfs_has_attr2(mp) &&
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) && (dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
!(args->op_flags & XFS_DA_OP_ADDNAME)) { !(args->op_flags & (XFS_DA_OP_ADDNAME | XFS_DA_OP_REPLACE))) {
xfs_attr_fork_remove(dp, args->trans); xfs_attr_fork_remove(dp, args->trans);
} else { } else {
xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
...@@ -1127,9 +1157,17 @@ xfs_attr3_leaf_to_shortform( ...@@ -1127,9 +1157,17 @@ xfs_attr3_leaf_to_shortform(
goto out; goto out;
if (forkoff == -1) { if (forkoff == -1) {
ASSERT(xfs_has_attr2(dp->i_mount)); /*
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE); * Don't remove the attr fork if this operation is the first
xfs_attr_fork_remove(dp, args->trans); * part of a attr replace operations. We're going to add a new
* attr immediately, so we need to keep the attr fork around in
* this case.
*/
if (!(args->op_flags & XFS_DA_OP_REPLACE)) {
ASSERT(xfs_has_attr2(dp->i_mount));
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE);
xfs_attr_fork_remove(dp, args->trans);
}
goto out; goto out;
} }
...@@ -1189,6 +1227,11 @@ xfs_attr3_leaf_to_node( ...@@ -1189,6 +1227,11 @@ xfs_attr3_leaf_to_node(
trace_xfs_attr_leaf_to_node(args); trace_xfs_attr_leaf_to_node(args);
if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
error = -EIO;
goto out;
}
error = xfs_da_grow_inode(args, &blkno); error = xfs_da_grow_inode(args, &blkno);
if (error) if (error)
goto out; goto out;
...@@ -1486,8 +1529,9 @@ xfs_attr3_leaf_add_work( ...@@ -1486,8 +1529,9 @@ xfs_attr3_leaf_add_work(
entry->flags = args->attr_filter; entry->flags = args->attr_filter;
if (tmp) if (tmp)
entry->flags |= XFS_ATTR_LOCAL; entry->flags |= XFS_ATTR_LOCAL;
if (args->op_flags & XFS_DA_OP_RENAME) { if (args->op_flags & XFS_DA_OP_REPLACE) {
entry->flags |= XFS_ATTR_INCOMPLETE; if (!xfs_has_larp(mp))
entry->flags |= XFS_ATTR_INCOMPLETE;
if ((args->blkno2 == args->blkno) && if ((args->blkno2 == args->blkno) &&
(args->index2 <= args->index)) { (args->index2 <= args->index)) {
args->index2++; args->index2++;
......
...@@ -568,14 +568,14 @@ xfs_attr_rmtval_stale( ...@@ -568,14 +568,14 @@ xfs_attr_rmtval_stale(
*/ */
int int
xfs_attr_rmtval_find_space( xfs_attr_rmtval_find_space(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_bmbt_irec *map = &dac->map; struct xfs_bmbt_irec *map = &attr->xattri_map;
int error; int error;
dac->lblkno = 0; attr->xattri_lblkno = 0;
dac->blkcnt = 0; attr->xattri_blkcnt = 0;
args->rmtblkcnt = 0; args->rmtblkcnt = 0;
args->rmtblkno = 0; args->rmtblkno = 0;
memset(map, 0, sizeof(struct xfs_bmbt_irec)); memset(map, 0, sizeof(struct xfs_bmbt_irec));
...@@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space( ...@@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space(
if (error) if (error)
return error; return error;
dac->blkcnt = args->rmtblkcnt; attr->xattri_blkcnt = args->rmtblkcnt;
dac->lblkno = args->rmtblkno; attr->xattri_lblkno = args->rmtblkno;
return 0; return 0;
} }
...@@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space( ...@@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space(
*/ */
int int
xfs_attr_rmtval_set_blk( xfs_attr_rmtval_set_blk(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_bmbt_irec *map = &dac->map; struct xfs_bmbt_irec *map = &attr->xattri_map;
int nmap; int nmap;
int error; int error;
nmap = 1; nmap = 1;
error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, error = xfs_bmapi_write(args->trans, dp,
dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, (xfs_fileoff_t)attr->xattri_lblkno,
attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total,
map, &nmap); map, &nmap);
if (error) if (error)
return error; return error;
...@@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk( ...@@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk(
(map->br_startblock != HOLESTARTBLOCK)); (map->br_startblock != HOLESTARTBLOCK));
/* roll attribute extent map forwards */ /* roll attribute extent map forwards */
dac->lblkno += map->br_blockcount; attr->xattri_lblkno += map->br_blockcount;
dac->blkcnt -= map->br_blockcount; attr->xattri_blkcnt -= map->br_blockcount;
return 0; return 0;
} }
...@@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate( ...@@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate(
*/ */
int int
xfs_attr_rmtval_remove( xfs_attr_rmtval_remove(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
int error, done; int error, done;
/* /*
...@@ -695,8 +696,8 @@ xfs_attr_rmtval_remove( ...@@ -695,8 +696,8 @@ xfs_attr_rmtval_remove(
* the parent * the parent
*/ */
if (!done) { if (!done) {
dac->flags |= XFS_DAC_DEFER_FINISH; trace_xfs_attr_rmtval_remove_return(attr->xattri_dela_state,
trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); args->dp);
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args); ...@@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args);
int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map,
xfs_buf_flags_t incore_flags); xfs_buf_flags_t incore_flags);
int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args);
int xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); int xfs_attr_rmtval_remove(struct xfs_attr_item *attr);
int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmt_find_hole(struct xfs_da_args *args);
int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args);
int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); int xfs_attr_rmtval_set_blk(struct xfs_attr_item *attr);
int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); int xfs_attr_rmtval_find_space(struct xfs_attr_item *attr);
#endif /* __XFS_ATTR_REMOTE_H__ */ #endif /* __XFS_ATTR_REMOTE_H__ */
This diff is collapsed.
...@@ -39,7 +39,7 @@ struct xfs_bmalloca { ...@@ -39,7 +39,7 @@ struct xfs_bmalloca {
bool aeof; /* allocated space at eof */ bool aeof; /* allocated space at eof */
bool conv; /* overwriting unwritten extents */ bool conv; /* overwriting unwritten extents */
int datatype;/* data type being allocated */ int datatype;/* data type being allocated */
int flags; uint32_t flags;
}; };
#define XFS_BMAP_MAX_NMAP 4 #define XFS_BMAP_MAX_NMAP 4
...@@ -47,17 +47,17 @@ struct xfs_bmalloca { ...@@ -47,17 +47,17 @@ struct xfs_bmalloca {
/* /*
* Flags for xfs_bmapi_* * Flags for xfs_bmapi_*
*/ */
#define XFS_BMAPI_ENTIRE 0x001 /* return entire extent, not trimmed */ #define XFS_BMAPI_ENTIRE (1u << 0) /* return entire extent untrimmed */
#define XFS_BMAPI_METADATA 0x002 /* mapping metadata not user data */ #define XFS_BMAPI_METADATA (1u << 1) /* mapping metadata not user data */
#define XFS_BMAPI_ATTRFORK 0x004 /* use attribute fork not data */ #define XFS_BMAPI_ATTRFORK (1u << 2) /* use attribute fork not data */
#define XFS_BMAPI_PREALLOC 0x008 /* preallocation op: unwritten space */ #define XFS_BMAPI_PREALLOC (1u << 3) /* preallocating unwritten space */
#define XFS_BMAPI_CONTIG 0x020 /* must allocate only one extent */ #define XFS_BMAPI_CONTIG (1u << 4) /* must allocate only one extent */
/* /*
* unwritten extent conversion - this needs write cache flushing and no additional * unwritten extent conversion - this needs write cache flushing and no additional
* allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts * allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts
* from written to unwritten, otherwise convert from unwritten to written. * from written to unwritten, otherwise convert from unwritten to written.
*/ */
#define XFS_BMAPI_CONVERT 0x040 #define XFS_BMAPI_CONVERT (1u << 5)
/* /*
* allocate zeroed extents - this requires all newly allocated user data extents * allocate zeroed extents - this requires all newly allocated user data extents
...@@ -65,7 +65,7 @@ struct xfs_bmalloca { ...@@ -65,7 +65,7 @@ struct xfs_bmalloca {
* Use in conjunction with XFS_BMAPI_CONVERT to convert unwritten extents found * Use in conjunction with XFS_BMAPI_CONVERT to convert unwritten extents found
* during the allocation range to zeroed written extents. * during the allocation range to zeroed written extents.
*/ */
#define XFS_BMAPI_ZERO 0x080 #define XFS_BMAPI_ZERO (1u << 6)
/* /*
* Map the inode offset to the block given in ap->firstblock. Primarily * Map the inode offset to the block given in ap->firstblock. Primarily
...@@ -75,16 +75,16 @@ struct xfs_bmalloca { ...@@ -75,16 +75,16 @@ struct xfs_bmalloca {
* For bunmapi, this flag unmaps the range without adjusting quota, reducing * For bunmapi, this flag unmaps the range without adjusting quota, reducing
* refcount, or freeing the blocks. * refcount, or freeing the blocks.
*/ */
#define XFS_BMAPI_REMAP 0x100 #define XFS_BMAPI_REMAP (1u << 7)
/* Map something in the CoW fork. */ /* Map something in the CoW fork. */
#define XFS_BMAPI_COWFORK 0x200 #define XFS_BMAPI_COWFORK (1u << 8)
/* Skip online discard of freed extents */ /* Skip online discard of freed extents */
#define XFS_BMAPI_NODISCARD 0x1000 #define XFS_BMAPI_NODISCARD (1u << 9)
/* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */ /* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */
#define XFS_BMAPI_NORMAP 0x2000 #define XFS_BMAPI_NORMAP (1u << 10)
#define XFS_BMAPI_FLAGS \ #define XFS_BMAPI_FLAGS \
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \
...@@ -106,7 +106,7 @@ static inline int xfs_bmapi_aflag(int w) ...@@ -106,7 +106,7 @@ static inline int xfs_bmapi_aflag(int w)
(w == XFS_COW_FORK ? XFS_BMAPI_COWFORK : 0)); (w == XFS_COW_FORK ? XFS_BMAPI_COWFORK : 0));
} }
static inline int xfs_bmapi_whichfork(int bmapi_flags) static inline int xfs_bmapi_whichfork(uint32_t bmapi_flags)
{ {
if (bmapi_flags & XFS_BMAPI_COWFORK) if (bmapi_flags & XFS_BMAPI_COWFORK)
return XFS_COW_FORK; return XFS_COW_FORK;
...@@ -124,16 +124,16 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags) ...@@ -124,16 +124,16 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags)
/* /*
* Flags for xfs_bmap_add_extent*. * Flags for xfs_bmap_add_extent*.
*/ */
#define BMAP_LEFT_CONTIG (1 << 0) #define BMAP_LEFT_CONTIG (1u << 0)
#define BMAP_RIGHT_CONTIG (1 << 1) #define BMAP_RIGHT_CONTIG (1u << 1)
#define BMAP_LEFT_FILLING (1 << 2) #define BMAP_LEFT_FILLING (1u << 2)
#define BMAP_RIGHT_FILLING (1 << 3) #define BMAP_RIGHT_FILLING (1u << 3)
#define BMAP_LEFT_DELAY (1 << 4) #define BMAP_LEFT_DELAY (1u << 4)
#define BMAP_RIGHT_DELAY (1 << 5) #define BMAP_RIGHT_DELAY (1u << 5)
#define BMAP_LEFT_VALID (1 << 6) #define BMAP_LEFT_VALID (1u << 6)
#define BMAP_RIGHT_VALID (1 << 7) #define BMAP_RIGHT_VALID (1u << 7)
#define BMAP_ATTRFORK (1 << 8) #define BMAP_ATTRFORK (1u << 8)
#define BMAP_COWFORK (1 << 9) #define BMAP_COWFORK (1u << 9)
#define XFS_BMAP_EXT_FLAGS \ #define XFS_BMAP_EXT_FLAGS \
{ BMAP_LEFT_CONTIG, "LC" }, \ { BMAP_LEFT_CONTIG, "LC" }, \
...@@ -183,15 +183,15 @@ int xfs_bmap_last_offset(struct xfs_inode *ip, xfs_fileoff_t *unused, ...@@ -183,15 +183,15 @@ int xfs_bmap_last_offset(struct xfs_inode *ip, xfs_fileoff_t *unused,
int whichfork); int whichfork);
int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno, int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
xfs_filblks_t len, struct xfs_bmbt_irec *mval, xfs_filblks_t len, struct xfs_bmbt_irec *mval,
int *nmap, int flags); int *nmap, uint32_t flags);
int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t bno, xfs_filblks_t len, int flags, xfs_fileoff_t bno, xfs_filblks_t len, uint32_t flags,
xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap); xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
int __xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, int __xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags, xfs_fileoff_t bno, xfs_filblks_t *rlen, uint32_t flags,
xfs_extnum_t nexts); xfs_extnum_t nexts);
int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t bno, xfs_filblks_t len, int flags, xfs_fileoff_t bno, xfs_filblks_t len, uint32_t flags,
xfs_extnum_t nexts, int *done); xfs_extnum_t nexts, int *done);
int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork, int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got, struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
...@@ -243,7 +243,7 @@ void xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip, ...@@ -243,7 +243,7 @@ void xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
void xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip, void xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
struct xfs_bmbt_irec *imap); struct xfs_bmbt_irec *imap);
static inline int xfs_bmap_fork_to_state(int whichfork) static inline uint32_t xfs_bmap_fork_to_state(int whichfork)
{ {
switch (whichfork) { switch (whichfork) {
case XFS_ATTR_FORK: case XFS_ATTR_FORK:
...@@ -260,7 +260,7 @@ xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork, ...@@ -260,7 +260,7 @@ xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
int xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock, xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock,
int flags); uint32_t flags);
extern struct kmem_cache *xfs_bmap_intent_cache; extern struct kmem_cache *xfs_bmap_intent_cache;
......
...@@ -597,7 +597,11 @@ xfs_bmbt_maxrecs( ...@@ -597,7 +597,11 @@ xfs_bmbt_maxrecs(
return xfs_bmbt_block_maxrecs(blocklen, leaf); return xfs_bmbt_block_maxrecs(blocklen, leaf);
} }
/* Compute the max possible height for block mapping btrees. */ /*
* Calculate the maximum possible height of the btree that the on-disk format
* supports. This is used for sizing structures large enough to support every
* possible configuration of a filesystem that might get mounted.
*/
unsigned int unsigned int
xfs_bmbt_maxlevels_ondisk(void) xfs_bmbt_maxlevels_ondisk(void)
{ {
...@@ -611,7 +615,8 @@ xfs_bmbt_maxlevels_ondisk(void) ...@@ -611,7 +615,8 @@ xfs_bmbt_maxlevels_ondisk(void)
minrecs[1] = xfs_bmbt_block_maxrecs(blocklen, false) / 2; minrecs[1] = xfs_bmbt_block_maxrecs(blocklen, false) / 2;
/* One extra level for the inode root. */ /* One extra level for the inode root. */
return xfs_btree_compute_maxlevels(minrecs, MAXEXTNUM) + 1; return xfs_btree_compute_maxlevels(minrecs,
XFS_MAX_EXTCNT_DATA_FORK_LARGE) + 1;
} }
/* /*
......
...@@ -51,6 +51,52 @@ xfs_btree_magic( ...@@ -51,6 +51,52 @@ xfs_btree_magic(
return magic; return magic;
} }
static xfs_failaddr_t
xfs_btree_check_lblock_siblings(
struct xfs_mount *mp,
struct xfs_btree_cur *cur,
int level,
xfs_fsblock_t fsb,
xfs_fsblock_t sibling)
{
if (sibling == NULLFSBLOCK)
return NULL;
if (sibling == fsb)
return __this_address;
if (level >= 0) {
if (!xfs_btree_check_lptr(cur, sibling, level + 1))
return __this_address;
} else {
if (!xfs_verify_fsbno(mp, sibling))
return __this_address;
}
return NULL;
}
static xfs_failaddr_t
xfs_btree_check_sblock_siblings(
struct xfs_mount *mp,
struct xfs_btree_cur *cur,
int level,
xfs_agnumber_t agno,
xfs_agblock_t agbno,
xfs_agblock_t sibling)
{
if (sibling == NULLAGBLOCK)
return NULL;
if (sibling == agbno)
return __this_address;
if (level >= 0) {
if (!xfs_btree_check_sptr(cur, sibling, level + 1))
return __this_address;
} else {
if (!xfs_verify_agbno(mp, agno, sibling))
return __this_address;
}
return NULL;
}
/* /*
* Check a long btree block header. Return the address of the failing check, * Check a long btree block header. Return the address of the failing check,
* or NULL if everything is ok. * or NULL if everything is ok.
...@@ -65,6 +111,8 @@ __xfs_btree_check_lblock( ...@@ -65,6 +111,8 @@ __xfs_btree_check_lblock(
struct xfs_mount *mp = cur->bc_mp; struct xfs_mount *mp = cur->bc_mp;
xfs_btnum_t btnum = cur->bc_btnum; xfs_btnum_t btnum = cur->bc_btnum;
int crc = xfs_has_crc(mp); int crc = xfs_has_crc(mp);
xfs_failaddr_t fa;
xfs_fsblock_t fsb = NULLFSBLOCK;
if (crc) { if (crc) {
if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid))
...@@ -83,16 +131,16 @@ __xfs_btree_check_lblock( ...@@ -83,16 +131,16 @@ __xfs_btree_check_lblock(
if (be16_to_cpu(block->bb_numrecs) > if (be16_to_cpu(block->bb_numrecs) >
cur->bc_ops->get_maxrecs(cur, level)) cur->bc_ops->get_maxrecs(cur, level))
return __this_address; return __this_address;
if (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLFSBLOCK) &&
!xfs_btree_check_lptr(cur, be64_to_cpu(block->bb_u.l.bb_leftsib),
level + 1))
return __this_address;
if (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLFSBLOCK) &&
!xfs_btree_check_lptr(cur, be64_to_cpu(block->bb_u.l.bb_rightsib),
level + 1))
return __this_address;
return NULL; if (bp)
fsb = XFS_DADDR_TO_FSB(mp, xfs_buf_daddr(bp));
fa = xfs_btree_check_lblock_siblings(mp, cur, level, fsb,
be64_to_cpu(block->bb_u.l.bb_leftsib));
if (!fa)
fa = xfs_btree_check_lblock_siblings(mp, cur, level, fsb,
be64_to_cpu(block->bb_u.l.bb_rightsib));
return fa;
} }
/* Check a long btree block header. */ /* Check a long btree block header. */
...@@ -130,6 +178,9 @@ __xfs_btree_check_sblock( ...@@ -130,6 +178,9 @@ __xfs_btree_check_sblock(
struct xfs_mount *mp = cur->bc_mp; struct xfs_mount *mp = cur->bc_mp;
xfs_btnum_t btnum = cur->bc_btnum; xfs_btnum_t btnum = cur->bc_btnum;
int crc = xfs_has_crc(mp); int crc = xfs_has_crc(mp);
xfs_failaddr_t fa;
xfs_agblock_t agbno = NULLAGBLOCK;
xfs_agnumber_t agno = NULLAGNUMBER;
if (crc) { if (crc) {
if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
...@@ -146,16 +197,18 @@ __xfs_btree_check_sblock( ...@@ -146,16 +197,18 @@ __xfs_btree_check_sblock(
if (be16_to_cpu(block->bb_numrecs) > if (be16_to_cpu(block->bb_numrecs) >
cur->bc_ops->get_maxrecs(cur, level)) cur->bc_ops->get_maxrecs(cur, level))
return __this_address; return __this_address;
if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) &&
!xfs_btree_check_sptr(cur, be32_to_cpu(block->bb_u.s.bb_leftsib),
level + 1))
return __this_address;
if (block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK) &&
!xfs_btree_check_sptr(cur, be32_to_cpu(block->bb_u.s.bb_rightsib),
level + 1))
return __this_address;
return NULL; if (bp) {
agbno = xfs_daddr_to_agbno(mp, xfs_buf_daddr(bp));
agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp));
}
fa = xfs_btree_check_sblock_siblings(mp, cur, level, agno, agbno,
be32_to_cpu(block->bb_u.s.bb_leftsib));
if (!fa)
fa = xfs_btree_check_sblock_siblings(mp, cur, level, agno,
agbno, be32_to_cpu(block->bb_u.s.bb_rightsib));
return fa;
} }
/* Check a short btree block header. */ /* Check a short btree block header. */
...@@ -751,20 +804,20 @@ xfs_btree_lastrec( ...@@ -751,20 +804,20 @@ xfs_btree_lastrec(
*/ */
void void
xfs_btree_offsets( xfs_btree_offsets(
int64_t fields, /* bitmask of fields */ uint32_t fields, /* bitmask of fields */
const short *offsets, /* table of field offsets */ const short *offsets, /* table of field offsets */
int nbits, /* number of bits to inspect */ int nbits, /* number of bits to inspect */
int *first, /* output: first byte offset */ int *first, /* output: first byte offset */
int *last) /* output: last byte offset */ int *last) /* output: last byte offset */
{ {
int i; /* current bit number */ int i; /* current bit number */
int64_t imask; /* mask for current bit number */ uint32_t imask; /* mask for current bit number */
ASSERT(fields != 0); ASSERT(fields != 0);
/* /*
* Find the lowest bit, so the first byte offset. * Find the lowest bit, so the first byte offset.
*/ */
for (i = 0, imask = 1LL; ; i++, imask <<= 1) { for (i = 0, imask = 1u; ; i++, imask <<= 1) {
if (imask & fields) { if (imask & fields) {
*first = offsets[i]; *first = offsets[i];
break; break;
...@@ -773,7 +826,7 @@ xfs_btree_offsets( ...@@ -773,7 +826,7 @@ xfs_btree_offsets(
/* /*
* Find the highest bit, so the last byte offset. * Find the highest bit, so the last byte offset.
*/ */
for (i = nbits - 1, imask = 1LL << i; ; i--, imask >>= 1) { for (i = nbits - 1, imask = 1u << i; ; i--, imask >>= 1) {
if (imask & fields) { if (imask & fields) {
*last = offsets[i + 1] - 1; *last = offsets[i + 1] - 1;
break; break;
...@@ -1456,7 +1509,7 @@ void ...@@ -1456,7 +1509,7 @@ void
xfs_btree_log_block( xfs_btree_log_block(
struct xfs_btree_cur *cur, /* btree cursor */ struct xfs_btree_cur *cur, /* btree cursor */
struct xfs_buf *bp, /* buffer containing btree block */ struct xfs_buf *bp, /* buffer containing btree block */
int fields) /* mask of fields: XFS_BB_... */ uint32_t fields) /* mask of fields: XFS_BB_... */
{ {
int first; /* first byte offset logged */ int first; /* first byte offset logged */
int last; /* last byte offset logged */ int last; /* last byte offset logged */
...@@ -4271,6 +4324,21 @@ xfs_btree_visit_block( ...@@ -4271,6 +4324,21 @@ xfs_btree_visit_block(
if (xfs_btree_ptr_is_null(cur, &rptr)) if (xfs_btree_ptr_is_null(cur, &rptr))
return -ENOENT; return -ENOENT;
/*
* We only visit blocks once in this walk, so we have to avoid the
* internal xfs_btree_lookup_get_block() optimisation where it will
* return the same block without checking if the right sibling points
* back to us and creates a cyclic reference in the btree.
*/
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
if (be64_to_cpu(rptr.l) == XFS_DADDR_TO_FSB(cur->bc_mp,
xfs_buf_daddr(bp)))
return -EFSCORRUPTED;
} else {
if (be32_to_cpu(rptr.s) == xfs_daddr_to_agbno(cur->bc_mp,
xfs_buf_daddr(bp)))
return -EFSCORRUPTED;
}
return xfs_btree_lookup_get_block(cur, level, &rptr, &block); return xfs_btree_lookup_get_block(cur, level, &rptr, &block);
} }
...@@ -4445,20 +4513,21 @@ xfs_btree_lblock_verify( ...@@ -4445,20 +4513,21 @@ xfs_btree_lblock_verify(
{ {
struct xfs_mount *mp = bp->b_mount; struct xfs_mount *mp = bp->b_mount;
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
xfs_fsblock_t fsb;
xfs_failaddr_t fa;
/* numrecs verification */ /* numrecs verification */
if (be16_to_cpu(block->bb_numrecs) > max_recs) if (be16_to_cpu(block->bb_numrecs) > max_recs)
return __this_address; return __this_address;
/* sibling pointer verification */ /* sibling pointer verification */
if (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLFSBLOCK) && fsb = XFS_DADDR_TO_FSB(mp, xfs_buf_daddr(bp));
!xfs_verify_fsbno(mp, be64_to_cpu(block->bb_u.l.bb_leftsib))) fa = xfs_btree_check_lblock_siblings(mp, NULL, -1, fsb,
return __this_address; be64_to_cpu(block->bb_u.l.bb_leftsib));
if (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLFSBLOCK) && if (!fa)
!xfs_verify_fsbno(mp, be64_to_cpu(block->bb_u.l.bb_rightsib))) fa = xfs_btree_check_lblock_siblings(mp, NULL, -1, fsb,
return __this_address; be64_to_cpu(block->bb_u.l.bb_rightsib));
return fa;
return NULL;
} }
/** /**
...@@ -4499,7 +4568,9 @@ xfs_btree_sblock_verify( ...@@ -4499,7 +4568,9 @@ xfs_btree_sblock_verify(
{ {
struct xfs_mount *mp = bp->b_mount; struct xfs_mount *mp = bp->b_mount;
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
xfs_agblock_t agno; xfs_agnumber_t agno;
xfs_agblock_t agbno;
xfs_failaddr_t fa;
/* numrecs verification */ /* numrecs verification */
if (be16_to_cpu(block->bb_numrecs) > max_recs) if (be16_to_cpu(block->bb_numrecs) > max_recs)
...@@ -4507,14 +4578,13 @@ xfs_btree_sblock_verify( ...@@ -4507,14 +4578,13 @@ xfs_btree_sblock_verify(
/* sibling pointer verification */ /* sibling pointer verification */
agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp)); agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp));
if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) && agbno = xfs_daddr_to_agbno(mp, xfs_buf_daddr(bp));
!xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_leftsib))) fa = xfs_btree_check_sblock_siblings(mp, NULL, -1, agno, agbno,
return __this_address; be32_to_cpu(block->bb_u.s.bb_leftsib));
if (block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK) && if (!fa)
!xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_rightsib))) fa = xfs_btree_check_sblock_siblings(mp, NULL, -1, agno, agbno,
return __this_address; be32_to_cpu(block->bb_u.s.bb_rightsib));
return fa;
return NULL;
} }
/* /*
......
...@@ -68,19 +68,19 @@ uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum); ...@@ -68,19 +68,19 @@ uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum);
/* /*
* For logging record fields. * For logging record fields.
*/ */
#define XFS_BB_MAGIC (1 << 0) #define XFS_BB_MAGIC (1u << 0)
#define XFS_BB_LEVEL (1 << 1) #define XFS_BB_LEVEL (1u << 1)
#define XFS_BB_NUMRECS (1 << 2) #define XFS_BB_NUMRECS (1u << 2)
#define XFS_BB_LEFTSIB (1 << 3) #define XFS_BB_LEFTSIB (1u << 3)
#define XFS_BB_RIGHTSIB (1 << 4) #define XFS_BB_RIGHTSIB (1u << 4)
#define XFS_BB_BLKNO (1 << 5) #define XFS_BB_BLKNO (1u << 5)
#define XFS_BB_LSN (1 << 6) #define XFS_BB_LSN (1u << 6)
#define XFS_BB_UUID (1 << 7) #define XFS_BB_UUID (1u << 7)
#define XFS_BB_OWNER (1 << 8) #define XFS_BB_OWNER (1u << 8)
#define XFS_BB_NUM_BITS 5 #define XFS_BB_NUM_BITS 5
#define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1) #define XFS_BB_ALL_BITS ((1u << XFS_BB_NUM_BITS) - 1)
#define XFS_BB_NUM_BITS_CRC 9 #define XFS_BB_NUM_BITS_CRC 9
#define XFS_BB_ALL_BITS_CRC ((1 << XFS_BB_NUM_BITS_CRC) - 1) #define XFS_BB_ALL_BITS_CRC ((1u << XFS_BB_NUM_BITS_CRC) - 1)
/* /*
* Generic stats interface * Generic stats interface
...@@ -345,7 +345,7 @@ xfs_btree_dup_cursor( ...@@ -345,7 +345,7 @@ xfs_btree_dup_cursor(
*/ */
void void
xfs_btree_offsets( xfs_btree_offsets(
int64_t fields, /* bitmask of fields */ uint32_t fields, /* bitmask of fields */
const short *offsets,/* table of field offsets */ const short *offsets,/* table of field offsets */
int nbits, /* number of bits to inspect */ int nbits, /* number of bits to inspect */
int *first, /* output: first byte offset */ int *first, /* output: first byte offset */
...@@ -435,7 +435,7 @@ bool xfs_btree_sblock_verify_crc(struct xfs_buf *); ...@@ -435,7 +435,7 @@ bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
/* /*
* Internal btree helpers also used by xfs_bmap.c. * Internal btree helpers also used by xfs_bmap.c.
*/ */
void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, int); void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, uint32_t);
void xfs_btree_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, int); void xfs_btree_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, int);
/* /*
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_errortag.h"
/* /*
* xfs_da_btree.c * xfs_da_btree.c
...@@ -482,6 +483,9 @@ xfs_da3_split( ...@@ -482,6 +483,9 @@ xfs_da3_split(
trace_xfs_da_split(state->args); trace_xfs_da_split(state->args);
if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
return -EIO;
/* /*
* Walk back up the tree splitting/inserting/adjusting as necessary. * Walk back up the tree splitting/inserting/adjusting as necessary.
* If we need to insert and there isn't room, split the node, then * If we need to insert and there isn't room, split the node, then
......
...@@ -30,6 +30,7 @@ struct xfs_da_geometry { ...@@ -30,6 +30,7 @@ struct xfs_da_geometry {
unsigned int free_hdr_size; /* dir2 free header size */ unsigned int free_hdr_size; /* dir2 free header size */
unsigned int free_max_bests; /* # of bests entries in dir2 free */ unsigned int free_max_bests; /* # of bests entries in dir2 free */
xfs_dablk_t freeblk; /* blockno of free data v2 */ xfs_dablk_t freeblk; /* blockno of free data v2 */
xfs_extnum_t max_extents; /* Max. extents in corresponding fork */
xfs_dir2_data_aoff_t data_first_offset; xfs_dir2_data_aoff_t data_first_offset;
size_t data_entry_offset; size_t data_entry_offset;
...@@ -76,27 +77,31 @@ typedef struct xfs_da_args { ...@@ -76,27 +77,31 @@ typedef struct xfs_da_args {
xfs_dablk_t rmtblkno2; /* remote attr value starting blkno */ xfs_dablk_t rmtblkno2; /* remote attr value starting blkno */
int rmtblkcnt2; /* remote attr value block count */ int rmtblkcnt2; /* remote attr value block count */
int rmtvaluelen2; /* remote attr value length in bytes */ int rmtvaluelen2; /* remote attr value length in bytes */
int op_flags; /* operation flags */ uint32_t op_flags; /* operation flags */
enum xfs_dacmp cmpresult; /* name compare result for lookups */ enum xfs_dacmp cmpresult; /* name compare result for lookups */
} xfs_da_args_t; } xfs_da_args_t;
/* /*
* Operation flags: * Operation flags:
*/ */
#define XFS_DA_OP_JUSTCHECK 0x0001 /* check for ok with no space */ #define XFS_DA_OP_JUSTCHECK (1u << 0) /* check for ok with no space */
#define XFS_DA_OP_RENAME 0x0002 /* this is an atomic rename op */ #define XFS_DA_OP_REPLACE (1u << 1) /* this is an atomic replace op */
#define XFS_DA_OP_ADDNAME 0x0004 /* this is an add operation */ #define XFS_DA_OP_ADDNAME (1u << 2) /* this is an add operation */
#define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */ #define XFS_DA_OP_OKNOENT (1u << 3) /* lookup op, ENOENT ok, else die */
#define XFS_DA_OP_CILOOKUP 0x0010 /* lookup to return CI name if found */ #define XFS_DA_OP_CILOOKUP (1u << 4) /* lookup returns CI name if found */
#define XFS_DA_OP_NOTIME 0x0020 /* don't update inode timestamps */ #define XFS_DA_OP_NOTIME (1u << 5) /* don't update inode timestamps */
#define XFS_DA_OP_REMOVE (1u << 6) /* this is a remove operation */
#define XFS_DA_OP_RECOVERY (1u << 7) /* Log recovery operation */
#define XFS_DA_OP_FLAGS \ #define XFS_DA_OP_FLAGS \
{ XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \ { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \
{ XFS_DA_OP_RENAME, "RENAME" }, \ { XFS_DA_OP_REPLACE, "REPLACE" }, \
{ XFS_DA_OP_ADDNAME, "ADDNAME" }, \ { XFS_DA_OP_ADDNAME, "ADDNAME" }, \
{ XFS_DA_OP_OKNOENT, "OKNOENT" }, \ { XFS_DA_OP_OKNOENT, "OKNOENT" }, \
{ XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \ { XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \
{ XFS_DA_OP_NOTIME, "NOTIME" } { XFS_DA_OP_NOTIME, "NOTIME" }, \
{ XFS_DA_OP_REMOVE, "REMOVE" }, \
{ XFS_DA_OP_RECOVERY, "RECOVERY" }
/* /*
* Storage for holding state during Btree searches and split/join ops. * Storage for holding state during Btree searches and split/join ops.
...@@ -197,7 +202,7 @@ int xfs_da3_node_read_mapped(struct xfs_trans *tp, struct xfs_inode *dp, ...@@ -197,7 +202,7 @@ int xfs_da3_node_read_mapped(struct xfs_trans *tp, struct xfs_inode *dp,
* Utility routines. * Utility routines.
*/ */
#define XFS_DABUF_MAP_HOLE_OK (1 << 0) #define XFS_DABUF_MAP_HOLE_OK (1u << 0)
int xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno); int xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno);
int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno, int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno,
......
...@@ -277,6 +277,7 @@ xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr) ...@@ -277,6 +277,7 @@ xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
* Directory address space divided into sections, * Directory address space divided into sections,
* spaces separated by 32GB. * spaces separated by 32GB.
*/ */
#define XFS_DIR2_MAX_SPACES 3
#define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG)) #define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
#define XFS_DIR2_DATA_SPACE 0 #define XFS_DIR2_DATA_SPACE 0
#define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE) #define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
...@@ -688,10 +689,10 @@ struct xfs_attr3_leafblock { ...@@ -688,10 +689,10 @@ struct xfs_attr3_leafblock {
#define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */ #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */
#define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */ #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */
#define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */ #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */
#define XFS_ATTR_LOCAL (1 << XFS_ATTR_LOCAL_BIT) #define XFS_ATTR_LOCAL (1u << XFS_ATTR_LOCAL_BIT)
#define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_ROOT (1u << XFS_ATTR_ROOT_BIT)
#define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT) #define XFS_ATTR_SECURE (1u << XFS_ATTR_SECURE_BIT)
#define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT) #define XFS_ATTR_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT)
#define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE)
/* /*
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include "xfs_refcount.h" #include "xfs_refcount.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_buf.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h"
static struct kmem_cache *xfs_defer_pending_cache; static struct kmem_cache *xfs_defer_pending_cache;
...@@ -184,9 +188,10 @@ static const struct xfs_defer_op_type *defer_op_types[] = { ...@@ -184,9 +188,10 @@ static const struct xfs_defer_op_type *defer_op_types[] = {
[XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type,
[XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type,
[XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type,
[XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type,
}; };
static void static bool
xfs_defer_create_intent( xfs_defer_create_intent(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_defer_pending *dfp, struct xfs_defer_pending *dfp,
...@@ -197,6 +202,7 @@ xfs_defer_create_intent( ...@@ -197,6 +202,7 @@ xfs_defer_create_intent(
if (!dfp->dfp_intent) if (!dfp->dfp_intent)
dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work,
dfp->dfp_count, sort); dfp->dfp_count, sort);
return dfp->dfp_intent != NULL;
} }
/* /*
...@@ -204,16 +210,18 @@ xfs_defer_create_intent( ...@@ -204,16 +210,18 @@ xfs_defer_create_intent(
* associated extents, then add the entire intake list to the end of * associated extents, then add the entire intake list to the end of
* the pending list. * the pending list.
*/ */
STATIC void static bool
xfs_defer_create_intents( xfs_defer_create_intents(
struct xfs_trans *tp) struct xfs_trans *tp)
{ {
struct xfs_defer_pending *dfp; struct xfs_defer_pending *dfp;
bool ret = false;
list_for_each_entry(dfp, &tp->t_dfops, dfp_list) { list_for_each_entry(dfp, &tp->t_dfops, dfp_list) {
trace_xfs_defer_create_intent(tp->t_mountp, dfp); trace_xfs_defer_create_intent(tp->t_mountp, dfp);
xfs_defer_create_intent(tp, dfp, true); ret |= xfs_defer_create_intent(tp, dfp, true);
} }
return ret;
} }
/* Abort all the intents that were committed. */ /* Abort all the intents that were committed. */
...@@ -487,7 +495,7 @@ int ...@@ -487,7 +495,7 @@ int
xfs_defer_finish_noroll( xfs_defer_finish_noroll(
struct xfs_trans **tp) struct xfs_trans **tp)
{ {
struct xfs_defer_pending *dfp; struct xfs_defer_pending *dfp = NULL;
int error = 0; int error = 0;
LIST_HEAD(dop_pending); LIST_HEAD(dop_pending);
...@@ -506,17 +514,20 @@ xfs_defer_finish_noroll( ...@@ -506,17 +514,20 @@ xfs_defer_finish_noroll(
* of time that any one intent item can stick around in memory, * of time that any one intent item can stick around in memory,
* pinning the log tail. * pinning the log tail.
*/ */
xfs_defer_create_intents(*tp); bool has_intents = xfs_defer_create_intents(*tp);
list_splice_init(&(*tp)->t_dfops, &dop_pending); list_splice_init(&(*tp)->t_dfops, &dop_pending);
error = xfs_defer_trans_roll(tp); if (has_intents || dfp) {
if (error) error = xfs_defer_trans_roll(tp);
goto out_shutdown; if (error)
goto out_shutdown;
/* Possibly relog intent items to keep the log moving. */ /* Relog intent items to keep the log moving. */
error = xfs_defer_relog(tp, &dop_pending); error = xfs_defer_relog(tp, &dop_pending);
if (error) if (error)
goto out_shutdown; goto out_shutdown;
}
dfp = list_first_entry(&dop_pending, struct xfs_defer_pending, dfp = list_first_entry(&dop_pending, struct xfs_defer_pending,
dfp_list); dfp_list);
...@@ -774,17 +785,25 @@ xfs_defer_ops_continue( ...@@ -774,17 +785,25 @@ xfs_defer_ops_continue(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_defer_resources *dres) struct xfs_defer_resources *dres)
{ {
unsigned int i;
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY));
/* Lock and join the captured inode to the new transaction. */ /* Lock the captured resources to the new transaction. */
if (dfc->dfc_held.dr_inos == 2) if (dfc->dfc_held.dr_inos == 2)
xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL,
dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL);
else if (dfc->dfc_held.dr_inos == 1) else if (dfc->dfc_held.dr_inos == 1)
xfs_ilock(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL); xfs_ilock(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL);
for (i = 0; i < dfc->dfc_held.dr_bufs; i++)
xfs_buf_lock(dfc->dfc_held.dr_bp[i]);
/* Join the captured resources to the new transaction. */
xfs_defer_restore_resources(tp, &dfc->dfc_held); xfs_defer_restore_resources(tp, &dfc->dfc_held);
memcpy(dres, &dfc->dfc_held, sizeof(struct xfs_defer_resources)); memcpy(dres, &dfc->dfc_held, sizeof(struct xfs_defer_resources));
dres->dr_bufs = 0;
/* Move captured dfops chain and state to the transaction. */ /* Move captured dfops chain and state to the transaction. */
list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); list_splice_init(&dfc->dfc_dfops, &tp->t_dfops);
...@@ -854,7 +873,12 @@ xfs_defer_init_item_caches(void) ...@@ -854,7 +873,12 @@ xfs_defer_init_item_caches(void)
error = xfs_extfree_intent_init_cache(); error = xfs_extfree_intent_init_cache();
if (error) if (error)
goto err; goto err;
error = xfs_attri_init_cache();
if (error)
goto err;
error = xfs_attrd_init_cache();
if (error)
goto err;
return 0; return 0;
err: err:
xfs_defer_destroy_item_caches(); xfs_defer_destroy_item_caches();
...@@ -865,6 +889,8 @@ xfs_defer_init_item_caches(void) ...@@ -865,6 +889,8 @@ xfs_defer_init_item_caches(void)
void void
xfs_defer_destroy_item_caches(void) xfs_defer_destroy_item_caches(void)
{ {
xfs_attri_destroy_cache();
xfs_attrd_destroy_cache();
xfs_extfree_intent_destroy_cache(); xfs_extfree_intent_destroy_cache();
xfs_bmap_intent_destroy_cache(); xfs_bmap_intent_destroy_cache();
xfs_refcount_intent_destroy_cache(); xfs_refcount_intent_destroy_cache();
......
...@@ -19,6 +19,7 @@ enum xfs_defer_ops_type { ...@@ -19,6 +19,7 @@ enum xfs_defer_ops_type {
XFS_DEFER_OPS_TYPE_RMAP, XFS_DEFER_OPS_TYPE_RMAP,
XFS_DEFER_OPS_TYPE_FREE, XFS_DEFER_OPS_TYPE_FREE,
XFS_DEFER_OPS_TYPE_AGFL_FREE, XFS_DEFER_OPS_TYPE_AGFL_FREE,
XFS_DEFER_OPS_TYPE_ATTR,
XFS_DEFER_OPS_TYPE_MAX, XFS_DEFER_OPS_TYPE_MAX,
}; };
...@@ -63,6 +64,8 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; ...@@ -63,6 +64,8 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
extern const struct xfs_defer_op_type xfs_attr_defer_type;
/* /*
* Deferred operation item relogging limits. * Deferred operation item relogging limits.
......
...@@ -150,6 +150,8 @@ xfs_da_mount( ...@@ -150,6 +150,8 @@ xfs_da_mount(
dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET); dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET);
dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) /
(uint)sizeof(xfs_da_node_entry_t); (uint)sizeof(xfs_da_node_entry_t);
dageo->max_extents = (XFS_DIR2_MAX_SPACES * XFS_DIR2_SPACE_SIZE) >>
mp->m_sb.sb_blocklog;
dageo->magicpct = (dageo->blksize * 37) / 100; dageo->magicpct = (dageo->blksize * 37) / 100;
/* set up attribute geometry - single fsb only */ /* set up attribute geometry - single fsb only */
...@@ -161,6 +163,12 @@ xfs_da_mount( ...@@ -161,6 +163,12 @@ xfs_da_mount(
dageo->node_hdr_size = mp->m_dir_geo->node_hdr_size; dageo->node_hdr_size = mp->m_dir_geo->node_hdr_size;
dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) /
(uint)sizeof(xfs_da_node_entry_t); (uint)sizeof(xfs_da_node_entry_t);
if (xfs_has_large_extent_counts(mp))
dageo->max_extents = XFS_MAX_EXTCNT_ATTR_FORK_LARGE;
else
dageo->max_extents = XFS_MAX_EXTCNT_ATTR_FORK_SMALL;
dageo->magicpct = (dageo->blksize * 37) / 100; dageo->magicpct = (dageo->blksize * 37) / 100;
return 0; return 0;
} }
......
...@@ -59,7 +59,10 @@ ...@@ -59,7 +59,10 @@
#define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36
#define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37
#define XFS_ERRTAG_AG_RESV_FAIL 38 #define XFS_ERRTAG_AG_RESV_FAIL 38
#define XFS_ERRTAG_MAX 39 #define XFS_ERRTAG_LARP 39
#define XFS_ERRTAG_DA_LEAF_SPLIT 40
#define XFS_ERRTAG_ATTR_LEAF_TO_NODE 41
#define XFS_ERRTAG_MAX 42
/* /*
* Random factors for above tags, 1 means always, 2 means 1/2 time, etc. * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
...@@ -103,5 +106,8 @@ ...@@ -103,5 +106,8 @@
#define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1 #define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1
#define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1 #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1
#define XFS_RANDOM_AG_RESV_FAIL 1 #define XFS_RANDOM_AG_RESV_FAIL 1
#define XFS_RANDOM_LARP 1
#define XFS_RANDOM_DA_LEAF_SPLIT 1
#define XFS_RANDOM_ATTR_LEAF_TO_NODE 1
#endif /* __XFS_ERRORTAG_H_ */ #endif /* __XFS_ERRORTAG_H_ */
This diff is collapsed.
...@@ -236,6 +236,7 @@ typedef struct xfs_fsop_resblks { ...@@ -236,6 +236,7 @@ typedef struct xfs_fsop_resblks {
#define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */ #define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */
#define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */
#define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */
#define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */
/* /*
* Minimum and maximum sizes need for growth checks. * Minimum and maximum sizes need for growth checks.
...@@ -377,7 +378,7 @@ struct xfs_bulkstat { ...@@ -377,7 +378,7 @@ struct xfs_bulkstat {
uint32_t bs_extsize_blks; /* extent size hint, blocks */ uint32_t bs_extsize_blks; /* extent size hint, blocks */
uint32_t bs_nlink; /* number of links */ uint32_t bs_nlink; /* number of links */
uint32_t bs_extents; /* number of extents */ uint32_t bs_extents; /* 32-bit data fork extent counter */
uint32_t bs_aextents; /* attribute number of extents */ uint32_t bs_aextents; /* attribute number of extents */
uint16_t bs_version; /* structure version */ uint16_t bs_version; /* structure version */
uint16_t bs_forkoff; /* inode fork offset in bytes */ uint16_t bs_forkoff; /* inode fork offset in bytes */
...@@ -386,8 +387,9 @@ struct xfs_bulkstat { ...@@ -386,8 +387,9 @@ struct xfs_bulkstat {
uint16_t bs_checked; /* checked inode metadata */ uint16_t bs_checked; /* checked inode metadata */
uint16_t bs_mode; /* type and mode */ uint16_t bs_mode; /* type and mode */
uint16_t bs_pad2; /* zeroed */ uint16_t bs_pad2; /* zeroed */
uint64_t bs_extents64; /* 64-bit data fork extent counter */
uint64_t bs_pad[7]; /* zeroed */ uint64_t bs_pad[6]; /* zeroed */
}; };
#define XFS_BULKSTAT_VERSION_V1 (1) #define XFS_BULKSTAT_VERSION_V1 (1)
...@@ -459,17 +461,28 @@ struct xfs_bulk_ireq { ...@@ -459,17 +461,28 @@ struct xfs_bulk_ireq {
* Only return results from the specified @agno. If @ino is zero, start * Only return results from the specified @agno. If @ino is zero, start
* with the first inode of @agno. * with the first inode of @agno.
*/ */
#define XFS_BULK_IREQ_AGNO (1 << 0) #define XFS_BULK_IREQ_AGNO (1U << 0)
/* /*
* Return bulkstat information for a single inode, where @ino value is a * Return bulkstat information for a single inode, where @ino value is a
* special value, not a literal inode number. See the XFS_BULK_IREQ_SPECIAL_* * special value, not a literal inode number. See the XFS_BULK_IREQ_SPECIAL_*
* values below. Not compatible with XFS_BULK_IREQ_AGNO. * values below. Not compatible with XFS_BULK_IREQ_AGNO.
*/ */
#define XFS_BULK_IREQ_SPECIAL (1 << 1) #define XFS_BULK_IREQ_SPECIAL (1U << 1)
#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ /*
XFS_BULK_IREQ_SPECIAL) * Return data fork extent count via xfs_bulkstat->bs_extents64 field and assign
* 0 to xfs_bulkstat->bs_extents when the flag is set. Otherwise, use
* xfs_bulkstat->bs_extents for returning data fork extent count and set
* xfs_bulkstat->bs_extents64 to 0. In the second case, return -EOVERFLOW and
* assign 0 to xfs_bulkstat->bs_extents if data fork extent count is larger than
* XFS_MAX_EXTCNT_DATA_FORK_OLD.
*/
#define XFS_BULK_IREQ_NREXT64 (1U << 2)
#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \
XFS_BULK_IREQ_SPECIAL | \
XFS_BULK_IREQ_NREXT64)
/* Operate on the root directory inode. */ /* Operate on the root directory inode. */
#define XFS_BULK_IREQ_SPECIAL_ROOT (1) #define XFS_BULK_IREQ_SPECIAL_ROOT (1)
...@@ -699,34 +712,34 @@ struct xfs_scrub_metadata { ...@@ -699,34 +712,34 @@ struct xfs_scrub_metadata {
#define XFS_SCRUB_TYPE_NR 25 #define XFS_SCRUB_TYPE_NR 25
/* i: Repair this metadata. */ /* i: Repair this metadata. */
#define XFS_SCRUB_IFLAG_REPAIR (1 << 0) #define XFS_SCRUB_IFLAG_REPAIR (1u << 0)
/* o: Metadata object needs repair. */ /* o: Metadata object needs repair. */
#define XFS_SCRUB_OFLAG_CORRUPT (1 << 1) #define XFS_SCRUB_OFLAG_CORRUPT (1u << 1)
/* /*
* o: Metadata object could be optimized. It's not corrupt, but * o: Metadata object could be optimized. It's not corrupt, but
* we could improve on it somehow. * we could improve on it somehow.
*/ */
#define XFS_SCRUB_OFLAG_PREEN (1 << 2) #define XFS_SCRUB_OFLAG_PREEN (1u << 2)
/* o: Cross-referencing failed. */ /* o: Cross-referencing failed. */
#define XFS_SCRUB_OFLAG_XFAIL (1 << 3) #define XFS_SCRUB_OFLAG_XFAIL (1u << 3)
/* o: Metadata object disagrees with cross-referenced metadata. */ /* o: Metadata object disagrees with cross-referenced metadata. */
#define XFS_SCRUB_OFLAG_XCORRUPT (1 << 4) #define XFS_SCRUB_OFLAG_XCORRUPT (1u << 4)
/* o: Scan was not complete. */ /* o: Scan was not complete. */
#define XFS_SCRUB_OFLAG_INCOMPLETE (1 << 5) #define XFS_SCRUB_OFLAG_INCOMPLETE (1u << 5)
/* o: Metadata object looked funny but isn't corrupt. */ /* o: Metadata object looked funny but isn't corrupt. */
#define XFS_SCRUB_OFLAG_WARNING (1 << 6) #define XFS_SCRUB_OFLAG_WARNING (1u << 6)
/* /*
* o: IFLAG_REPAIR was set but metadata object did not need fixing or * o: IFLAG_REPAIR was set but metadata object did not need fixing or
* optimization and has therefore not been altered. * optimization and has therefore not been altered.
*/ */
#define XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED (1 << 7) #define XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED (1u << 7)
#define XFS_SCRUB_FLAGS_IN (XFS_SCRUB_IFLAG_REPAIR) #define XFS_SCRUB_FLAGS_IN (XFS_SCRUB_IFLAG_REPAIR)
#define XFS_SCRUB_FLAGS_OUT (XFS_SCRUB_OFLAG_CORRUPT | \ #define XFS_SCRUB_FLAGS_OUT (XFS_SCRUB_OFLAG_CORRUPT | \
......
...@@ -2414,9 +2414,9 @@ xfs_imap( ...@@ -2414,9 +2414,9 @@ xfs_imap(
*/ */
void void
xfs_ialloc_log_agi( xfs_ialloc_log_agi(
xfs_trans_t *tp, /* transaction pointer */ struct xfs_trans *tp,
struct xfs_buf *bp, /* allocation group header buffer */ struct xfs_buf *bp,
int fields) /* bitmask of fields to log */ uint32_t fields)
{ {
int first; /* first byte number */ int first; /* first byte number */
int last; /* last byte number */ int last; /* last byte number */
...@@ -2772,6 +2772,8 @@ xfs_ialloc_setup_geometry( ...@@ -2772,6 +2772,8 @@ xfs_ialloc_setup_geometry(
igeo->new_diflags2 = 0; igeo->new_diflags2 = 0;
if (xfs_has_bigtime(mp)) if (xfs_has_bigtime(mp))
igeo->new_diflags2 |= XFS_DIFLAG2_BIGTIME; igeo->new_diflags2 |= XFS_DIFLAG2_BIGTIME;
if (xfs_has_large_extent_counts(mp))
igeo->new_diflags2 |= XFS_DIFLAG2_NREXT64;
/* Compute inode btree geometry. */ /* Compute inode btree geometry. */
igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog; igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
......
...@@ -60,7 +60,7 @@ void ...@@ -60,7 +60,7 @@ void
xfs_ialloc_log_agi( xfs_ialloc_log_agi(
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
struct xfs_buf *bp, /* allocation group header buffer */ struct xfs_buf *bp, /* allocation group header buffer */
int fields); /* bitmask of fields to log */ uint32_t fields); /* bitmask of fields to log */
/* /*
* Read in the allocation group header (inode allocation section) * Read in the allocation group header (inode allocation section)
......
...@@ -279,6 +279,25 @@ xfs_inode_to_disk_ts( ...@@ -279,6 +279,25 @@ xfs_inode_to_disk_ts(
return ts; return ts;
} }
static inline void
xfs_inode_to_disk_iext_counters(
struct xfs_inode *ip,
struct xfs_dinode *to)
{
if (xfs_inode_has_large_extent_counts(ip)) {
to->di_big_nextents = cpu_to_be64(xfs_ifork_nextents(&ip->i_df));
to->di_big_anextents = cpu_to_be32(xfs_ifork_nextents(ip->i_afp));
/*
* We might be upgrading the inode to use larger extent counters
* than was previously used. Hence zero the unused field.
*/
to->di_nrext64_pad = cpu_to_be16(0);
} else {
to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
}
}
void void
xfs_inode_to_disk( xfs_inode_to_disk(
struct xfs_inode *ip, struct xfs_inode *ip,
...@@ -296,7 +315,6 @@ xfs_inode_to_disk( ...@@ -296,7 +315,6 @@ xfs_inode_to_disk(
to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff); to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff);
to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16); to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16);
memset(to->di_pad, 0, sizeof(to->di_pad));
to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime); to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime);
to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime); to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime);
to->di_ctime = xfs_inode_to_disk_ts(ip, inode->i_ctime); to->di_ctime = xfs_inode_to_disk_ts(ip, inode->i_ctime);
...@@ -307,8 +325,6 @@ xfs_inode_to_disk( ...@@ -307,8 +325,6 @@ xfs_inode_to_disk(
to->di_size = cpu_to_be64(ip->i_disk_size); to->di_size = cpu_to_be64(ip->i_disk_size);
to->di_nblocks = cpu_to_be64(ip->i_nblocks); to->di_nblocks = cpu_to_be64(ip->i_nblocks);
to->di_extsize = cpu_to_be32(ip->i_extsize); to->di_extsize = cpu_to_be32(ip->i_extsize);
to->di_nextents = cpu_to_be32(xfs_ifork_nextents(&ip->i_df));
to->di_anextents = cpu_to_be16(xfs_ifork_nextents(ip->i_afp));
to->di_forkoff = ip->i_forkoff; to->di_forkoff = ip->i_forkoff;
to->di_aformat = xfs_ifork_format(ip->i_afp); to->di_aformat = xfs_ifork_format(ip->i_afp);
to->di_flags = cpu_to_be16(ip->i_diflags); to->di_flags = cpu_to_be16(ip->i_diflags);
...@@ -323,11 +339,14 @@ xfs_inode_to_disk( ...@@ -323,11 +339,14 @@ xfs_inode_to_disk(
to->di_lsn = cpu_to_be64(lsn); to->di_lsn = cpu_to_be64(lsn);
memset(to->di_pad2, 0, sizeof(to->di_pad2)); memset(to->di_pad2, 0, sizeof(to->di_pad2));
uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid);
to->di_flushiter = 0; to->di_v3_pad = 0;
} else { } else {
to->di_version = 2; to->di_version = 2;
to->di_flushiter = cpu_to_be16(ip->i_flushiter); to->di_flushiter = cpu_to_be16(ip->i_flushiter);
memset(to->di_v2_pad, 0, sizeof(to->di_v2_pad));
} }
xfs_inode_to_disk_iext_counters(ip, to);
} }
static xfs_failaddr_t static xfs_failaddr_t
...@@ -336,20 +355,40 @@ xfs_dinode_verify_fork( ...@@ -336,20 +355,40 @@ xfs_dinode_verify_fork(
struct xfs_mount *mp, struct xfs_mount *mp,
int whichfork) int whichfork)
{ {
uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork); xfs_extnum_t di_nextents;
xfs_extnum_t max_extents;
mode_t mode = be16_to_cpu(dip->di_mode);
uint32_t fork_size = XFS_DFORK_SIZE(dip, mp, whichfork);
uint32_t fork_format = XFS_DFORK_FORMAT(dip, whichfork);
di_nextents = xfs_dfork_nextents(dip, whichfork);
/*
* For fork types that can contain local data, check that the fork
* format matches the size of local data contained within the fork.
*
* For all types, check that when the size says the should be in extent
* or btree format, the inode isn't claiming it is in local format.
*/
if (whichfork == XFS_DATA_FORK) {
if (S_ISDIR(mode) || S_ISLNK(mode)) {
if (be64_to_cpu(dip->di_size) <= fork_size &&
fork_format != XFS_DINODE_FMT_LOCAL)
return __this_address;
}
switch (XFS_DFORK_FORMAT(dip, whichfork)) { if (be64_to_cpu(dip->di_size) > fork_size &&
fork_format == XFS_DINODE_FMT_LOCAL)
return __this_address;
}
switch (fork_format) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
/* /*
* no local regular files yet * No local regular files yet.
*/ */
if (whichfork == XFS_DATA_FORK) { if (S_ISREG(mode) && whichfork == XFS_DATA_FORK)
if (S_ISREG(be16_to_cpu(dip->di_mode))) return __this_address;
return __this_address;
if (be64_to_cpu(dip->di_size) >
XFS_DFORK_SIZE(dip, mp, whichfork))
return __this_address;
}
if (di_nextents) if (di_nextents)
return __this_address; return __this_address;
break; break;
...@@ -358,12 +397,11 @@ xfs_dinode_verify_fork( ...@@ -358,12 +397,11 @@ xfs_dinode_verify_fork(
return __this_address; return __this_address;
break; break;
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
if (whichfork == XFS_ATTR_FORK) { max_extents = xfs_iext_max_nextents(
if (di_nextents > MAXAEXTNUM) xfs_dinode_has_large_extent_counts(dip),
return __this_address; whichfork);
} else if (di_nextents > MAXEXTNUM) { if (di_nextents > max_extents)
return __this_address; return __this_address;
}
break; break;
default: default:
return __this_address; return __this_address;
...@@ -396,6 +434,24 @@ xfs_dinode_verify_forkoff( ...@@ -396,6 +434,24 @@ xfs_dinode_verify_forkoff(
return NULL; return NULL;
} }
static xfs_failaddr_t
xfs_dinode_verify_nrext64(
struct xfs_mount *mp,
struct xfs_dinode *dip)
{
if (xfs_dinode_has_large_extent_counts(dip)) {
if (!xfs_has_large_extent_counts(mp))
return __this_address;
if (dip->di_nrext64_pad != 0)
return __this_address;
} else if (dip->di_version >= 3) {
if (dip->di_v3_pad != 0)
return __this_address;
}
return NULL;
}
xfs_failaddr_t xfs_failaddr_t
xfs_dinode_verify( xfs_dinode_verify(
struct xfs_mount *mp, struct xfs_mount *mp,
...@@ -407,6 +463,9 @@ xfs_dinode_verify( ...@@ -407,6 +463,9 @@ xfs_dinode_verify(
uint16_t flags; uint16_t flags;
uint64_t flags2; uint64_t flags2;
uint64_t di_size; uint64_t di_size;
xfs_extnum_t nextents;
xfs_extnum_t naextents;
xfs_filblks_t nblocks;
if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
return __this_address; return __this_address;
...@@ -437,10 +496,19 @@ xfs_dinode_verify( ...@@ -437,10 +496,19 @@ xfs_dinode_verify(
if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0) if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0)
return __this_address; return __this_address;
fa = xfs_dinode_verify_nrext64(mp, dip);
if (fa)
return fa;
nextents = xfs_dfork_data_extents(dip);
naextents = xfs_dfork_attr_extents(dip);
nblocks = be64_to_cpu(dip->di_nblocks);
/* Fork checks carried over from xfs_iformat_fork */ /* Fork checks carried over from xfs_iformat_fork */
if (mode && if (mode && nextents + naextents > nblocks)
be32_to_cpu(dip->di_nextents) + be16_to_cpu(dip->di_anextents) > return __this_address;
be64_to_cpu(dip->di_nblocks))
if (S_ISDIR(mode) && nextents > mp->m_dir_geo->max_extents)
return __this_address; return __this_address;
if (mode && XFS_DFORK_BOFF(dip) > mp->m_sb.sb_inodesize) if (mode && XFS_DFORK_BOFF(dip) > mp->m_sb.sb_inodesize)
...@@ -497,7 +565,7 @@ xfs_dinode_verify( ...@@ -497,7 +565,7 @@ xfs_dinode_verify(
default: default:
return __this_address; return __this_address;
} }
if (dip->di_anextents) if (naextents)
return __this_address; return __this_address;
} }
...@@ -639,7 +707,7 @@ xfs_inode_validate_extsize( ...@@ -639,7 +707,7 @@ xfs_inode_validate_extsize(
if (extsize_bytes % blocksize_bytes) if (extsize_bytes % blocksize_bytes)
return __this_address; return __this_address;
if (extsize > MAXEXTLEN) if (extsize > XFS_MAX_BMBT_EXTLEN)
return __this_address; return __this_address;
if (!rt_flag && extsize > mp->m_sb.sb_agblocks / 2) if (!rt_flag && extsize > mp->m_sb.sb_agblocks / 2)
...@@ -696,7 +764,7 @@ xfs_inode_validate_cowextsize( ...@@ -696,7 +764,7 @@ xfs_inode_validate_cowextsize(
if (cowextsize_bytes % mp->m_sb.sb_blocksize) if (cowextsize_bytes % mp->m_sb.sb_blocksize)
return __this_address; return __this_address;
if (cowextsize > MAXEXTLEN) if (cowextsize > XFS_MAX_BMBT_EXTLEN)
return __this_address; return __this_address;
if (cowextsize > mp->m_sb.sb_agblocks / 2) if (cowextsize > mp->m_sb.sb_agblocks / 2)
......
...@@ -36,7 +36,7 @@ xfs_init_local_fork( ...@@ -36,7 +36,7 @@ xfs_init_local_fork(
int64_t size) int64_t size)
{ {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
int mem_size = size, real_size = 0; int mem_size = size;
bool zero_terminate; bool zero_terminate;
/* /*
...@@ -50,8 +50,7 @@ xfs_init_local_fork( ...@@ -50,8 +50,7 @@ xfs_init_local_fork(
mem_size++; mem_size++;
if (size) { if (size) {
real_size = roundup(mem_size, 4); ifp->if_u1.if_data = kmem_alloc(mem_size, KM_NOFS);
ifp->if_u1.if_data = kmem_alloc(real_size, KM_NOFS);
memcpy(ifp->if_u1.if_data, data, size); memcpy(ifp->if_u1.if_data, data, size);
if (zero_terminate) if (zero_terminate)
ifp->if_u1.if_data[size] = '\0'; ifp->if_u1.if_data[size] = '\0';
...@@ -105,7 +104,7 @@ xfs_iformat_extents( ...@@ -105,7 +104,7 @@ xfs_iformat_extents(
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
int state = xfs_bmap_fork_to_state(whichfork); int state = xfs_bmap_fork_to_state(whichfork);
int nex = XFS_DFORK_NEXTENTS(dip, whichfork); xfs_extnum_t nex = xfs_dfork_nextents(dip, whichfork);
int size = nex * sizeof(xfs_bmbt_rec_t); int size = nex * sizeof(xfs_bmbt_rec_t);
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
struct xfs_bmbt_rec *dp; struct xfs_bmbt_rec *dp;
...@@ -117,8 +116,8 @@ xfs_iformat_extents( ...@@ -117,8 +116,8 @@ xfs_iformat_extents(
* we just bail out rather than crash in kmem_alloc() or memcpy() below. * we just bail out rather than crash in kmem_alloc() or memcpy() below.
*/ */
if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, mp, whichfork))) { if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, mp, whichfork))) {
xfs_warn(ip->i_mount, "corrupt inode %Lu ((a)extents = %d).", xfs_warn(ip->i_mount, "corrupt inode %llu ((a)extents = %llu).",
(unsigned long long) ip->i_ino, nex); ip->i_ino, nex);
xfs_inode_verifier_error(ip, -EFSCORRUPTED, xfs_inode_verifier_error(ip, -EFSCORRUPTED,
"xfs_iformat_extents(1)", dip, sizeof(*dip), "xfs_iformat_extents(1)", dip, sizeof(*dip),
__this_address); __this_address);
...@@ -230,7 +229,7 @@ xfs_iformat_data_fork( ...@@ -230,7 +229,7 @@ xfs_iformat_data_fork(
* depend on it. * depend on it.
*/ */
ip->i_df.if_format = dip->di_format; ip->i_df.if_format = dip->di_format;
ip->i_df.if_nextents = be32_to_cpu(dip->di_nextents); ip->i_df.if_nextents = xfs_dfork_data_extents(dip);
switch (inode->i_mode & S_IFMT) { switch (inode->i_mode & S_IFMT) {
case S_IFIFO: case S_IFIFO:
...@@ -295,14 +294,14 @@ xfs_iformat_attr_fork( ...@@ -295,14 +294,14 @@ xfs_iformat_attr_fork(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_dinode *dip) struct xfs_dinode *dip)
{ {
xfs_extnum_t naextents = xfs_dfork_attr_extents(dip);
int error = 0; int error = 0;
/* /*
* Initialize the extent count early, as the per-format routines may * Initialize the extent count early, as the per-format routines may
* depend on it. * depend on it.
*/ */
ip->i_afp = xfs_ifork_alloc(dip->di_aformat, ip->i_afp = xfs_ifork_alloc(dip->di_aformat, naextents);
be16_to_cpu(dip->di_anextents));
switch (ip->i_afp->if_format) { switch (ip->i_afp->if_format) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
...@@ -497,12 +496,7 @@ xfs_idata_realloc( ...@@ -497,12 +496,7 @@ xfs_idata_realloc(
return; return;
} }
/* ifp->if_u1.if_data = krealloc(ifp->if_u1.if_data, new_size,
* For inline data, the underlying buffer must be a multiple of 4 bytes
* in size so that it can be logged and stay on word boundaries.
* We enforce that here.
*/
ifp->if_u1.if_data = krealloc(ifp->if_u1.if_data, roundup(new_size, 4),
GFP_NOFS | __GFP_NOFAIL); GFP_NOFS | __GFP_NOFAIL);
ifp->if_bytes = new_size; ifp->if_bytes = new_size;
} }
...@@ -744,7 +738,8 @@ xfs_iext_count_may_overflow( ...@@ -744,7 +738,8 @@ xfs_iext_count_may_overflow(
if (whichfork == XFS_COW_FORK) if (whichfork == XFS_COW_FORK)
return 0; return 0;
max_exts = (whichfork == XFS_ATTR_FORK) ? MAXAEXTNUM : MAXEXTNUM; max_exts = xfs_iext_max_nextents(xfs_inode_has_large_extent_counts(ip),
whichfork);
if (XFS_TEST_ERROR(false, ip->i_mount, XFS_ERRTAG_REDUCE_MAX_IEXTENTS)) if (XFS_TEST_ERROR(false, ip->i_mount, XFS_ERRTAG_REDUCE_MAX_IEXTENTS))
max_exts = 10; max_exts = 10;
...@@ -755,3 +750,27 @@ xfs_iext_count_may_overflow( ...@@ -755,3 +750,27 @@ xfs_iext_count_may_overflow(
return 0; return 0;
} }
/*
* Upgrade this inode's extent counter fields to be able to handle a potential
* increase in the extent count by nr_to_add. Normally this is the same
* quantity that caused xfs_iext_count_may_overflow() to return -EFBIG.
*/
int
xfs_iext_count_upgrade(
struct xfs_trans *tp,
struct xfs_inode *ip,
uint nr_to_add)
{
ASSERT(nr_to_add <= XFS_MAX_EXTCNT_UPGRADE_NR);
if (!xfs_has_large_extent_counts(ip->i_mount) ||
xfs_inode_has_large_extent_counts(ip) ||
XFS_TEST_ERROR(false, ip->i_mount, XFS_ERRTAG_REDUCE_MAX_IEXTENTS))
return -EFBIG;
ip->i_diflags2 |= XFS_DIFLAG2_NREXT64;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
return 0;
}
...@@ -21,9 +21,9 @@ struct xfs_ifork { ...@@ -21,9 +21,9 @@ struct xfs_ifork {
void *if_root; /* extent tree root */ void *if_root; /* extent tree root */
char *if_data; /* inline file data */ char *if_data; /* inline file data */
} if_u1; } if_u1;
xfs_extnum_t if_nextents; /* # of extents in this fork */
short if_broot_bytes; /* bytes allocated for root */ short if_broot_bytes; /* bytes allocated for root */
int8_t if_format; /* format of this fork */ int8_t if_format; /* format of this fork */
xfs_extnum_t if_nextents; /* # of extents in this fork */
}; };
/* /*
...@@ -39,19 +39,6 @@ struct xfs_ifork { ...@@ -39,19 +39,6 @@ struct xfs_ifork {
*/ */
#define XFS_IEXT_PUNCH_HOLE_CNT (1) #define XFS_IEXT_PUNCH_HOLE_CNT (1)
/*
* Directory entry addition can cause the following,
* 1. Data block can be added/removed.
* A new extent can cause extent count to increase by 1.
* 2. Free disk block can be added/removed.
* Same behaviour as described above for Data block.
* 3. Dabtree blocks.
* XFS_DA_NODE_MAXDEPTH blocks can be added. Each of these can be new
* extents. Hence extent count can increase by XFS_DA_NODE_MAXDEPTH.
*/
#define XFS_IEXT_DIR_MANIP_CNT(mp) \
((XFS_DA_NODE_MAXDEPTH + 1 + 1) * (mp)->m_dir_geo->fsbcount)
/* /*
* Adding/removing an xattr can cause XFS_DA_NODE_MAXDEPTH extents to * Adding/removing an xattr can cause XFS_DA_NODE_MAXDEPTH extents to
* be added. One extra extent for dabtree in case a local attr is * be added. One extra extent for dabtree in case a local attr is
...@@ -133,6 +120,65 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) ...@@ -133,6 +120,65 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp)
return ifp->if_format; return ifp->if_format;
} }
static inline xfs_extnum_t xfs_iext_max_nextents(bool has_large_extent_counts,
int whichfork)
{
switch (whichfork) {
case XFS_DATA_FORK:
case XFS_COW_FORK:
if (has_large_extent_counts)
return XFS_MAX_EXTCNT_DATA_FORK_LARGE;
return XFS_MAX_EXTCNT_DATA_FORK_SMALL;
case XFS_ATTR_FORK:
if (has_large_extent_counts)
return XFS_MAX_EXTCNT_ATTR_FORK_LARGE;
return XFS_MAX_EXTCNT_ATTR_FORK_SMALL;
default:
ASSERT(0);
return 0;
}
}
static inline xfs_extnum_t
xfs_dfork_data_extents(
struct xfs_dinode *dip)
{
if (xfs_dinode_has_large_extent_counts(dip))
return be64_to_cpu(dip->di_big_nextents);
return be32_to_cpu(dip->di_nextents);
}
static inline xfs_extnum_t
xfs_dfork_attr_extents(
struct xfs_dinode *dip)
{
if (xfs_dinode_has_large_extent_counts(dip))
return be32_to_cpu(dip->di_big_anextents);
return be16_to_cpu(dip->di_anextents);
}
static inline xfs_extnum_t
xfs_dfork_nextents(
struct xfs_dinode *dip,
int whichfork)
{
switch (whichfork) {
case XFS_DATA_FORK:
return xfs_dfork_data_extents(dip);
case XFS_ATTR_FORK:
return xfs_dfork_attr_extents(dip);
default:
ASSERT(0);
break;
}
return 0;
}
struct xfs_ifork *xfs_ifork_alloc(enum xfs_dinode_fmt format, struct xfs_ifork *xfs_ifork_alloc(enum xfs_dinode_fmt format,
xfs_extnum_t nextents); xfs_extnum_t nextents);
struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state);
...@@ -229,6 +275,8 @@ int xfs_ifork_verify_local_data(struct xfs_inode *ip); ...@@ -229,6 +275,8 @@ int xfs_ifork_verify_local_data(struct xfs_inode *ip);
int xfs_ifork_verify_local_attr(struct xfs_inode *ip); int xfs_ifork_verify_local_attr(struct xfs_inode *ip);
int xfs_iext_count_may_overflow(struct xfs_inode *ip, int whichfork, int xfs_iext_count_may_overflow(struct xfs_inode *ip, int whichfork,
int nr_to_add); int nr_to_add);
int xfs_iext_count_upgrade(struct xfs_trans *tp, struct xfs_inode *ip,
uint nr_to_add);
/* returns true if the fork has extents but they are not read in yet. */ /* returns true if the fork has extents but they are not read in yet. */
static inline bool xfs_need_iread_extents(struct xfs_ifork *ifp) static inline bool xfs_need_iread_extents(struct xfs_ifork *ifp)
......
...@@ -69,7 +69,6 @@ static inline uint xlog_get_cycle(char *ptr) ...@@ -69,7 +69,6 @@ static inline uint xlog_get_cycle(char *ptr)
/* Log Clients */ /* Log Clients */
#define XFS_TRANSACTION 0x69 #define XFS_TRANSACTION 0x69
#define XFS_VOLUME 0x2
#define XFS_LOG 0xaa #define XFS_LOG 0xaa
#define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
...@@ -114,7 +113,12 @@ struct xfs_unmount_log_format { ...@@ -114,7 +113,12 @@ struct xfs_unmount_log_format {
#define XLOG_REG_TYPE_CUD_FORMAT 24 #define XLOG_REG_TYPE_CUD_FORMAT 24
#define XLOG_REG_TYPE_BUI_FORMAT 25 #define XLOG_REG_TYPE_BUI_FORMAT 25
#define XLOG_REG_TYPE_BUD_FORMAT 26 #define XLOG_REG_TYPE_BUD_FORMAT 26
#define XLOG_REG_TYPE_MAX 26 #define XLOG_REG_TYPE_ATTRI_FORMAT 27
#define XLOG_REG_TYPE_ATTRD_FORMAT 28
#define XLOG_REG_TYPE_ATTR_NAME 29
#define XLOG_REG_TYPE_ATTR_VALUE 30
#define XLOG_REG_TYPE_MAX 30
/* /*
* Flags to log operation header * Flags to log operation header
...@@ -237,6 +241,8 @@ typedef struct xfs_trans_header { ...@@ -237,6 +241,8 @@ typedef struct xfs_trans_header {
#define XFS_LI_CUD 0x1243 #define XFS_LI_CUD 0x1243
#define XFS_LI_BUI 0x1244 /* bmbt update intent */ #define XFS_LI_BUI 0x1244 /* bmbt update intent */
#define XFS_LI_BUD 0x1245 #define XFS_LI_BUD 0x1245
#define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/
#define XFS_LI_ATTRD 0x1247 /* attr set/remove done */
#define XFS_LI_TYPE_DESC \ #define XFS_LI_TYPE_DESC \
{ XFS_LI_EFI, "XFS_LI_EFI" }, \ { XFS_LI_EFI, "XFS_LI_EFI" }, \
...@@ -252,7 +258,9 @@ typedef struct xfs_trans_header { ...@@ -252,7 +258,9 @@ typedef struct xfs_trans_header {
{ XFS_LI_CUI, "XFS_LI_CUI" }, \ { XFS_LI_CUI, "XFS_LI_CUI" }, \
{ XFS_LI_CUD, "XFS_LI_CUD" }, \ { XFS_LI_CUD, "XFS_LI_CUD" }, \
{ XFS_LI_BUI, "XFS_LI_BUI" }, \ { XFS_LI_BUI, "XFS_LI_BUI" }, \
{ XFS_LI_BUD, "XFS_LI_BUD" } { XFS_LI_BUD, "XFS_LI_BUD" }, \
{ XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \
{ XFS_LI_ATTRD, "XFS_LI_ATTRD" }
/* /*
* Inode Log Item Format definitions. * Inode Log Item Format definitions.
...@@ -388,16 +396,41 @@ struct xfs_log_dinode { ...@@ -388,16 +396,41 @@ struct xfs_log_dinode {
uint32_t di_nlink; /* number of links to file */ uint32_t di_nlink; /* number of links to file */
uint16_t di_projid_lo; /* lower part of owner's project id */ uint16_t di_projid_lo; /* lower part of owner's project id */
uint16_t di_projid_hi; /* higher part of owner's project id */ uint16_t di_projid_hi; /* higher part of owner's project id */
uint8_t di_pad[6]; /* unused, zeroed space */ union {
uint16_t di_flushiter; /* incremented on flush */ /* Number of data fork extents if NREXT64 is set */
uint64_t di_big_nextents;
/* Padding for V3 inodes without NREXT64 set. */
uint64_t di_v3_pad;
/* Padding and inode flush counter for V2 inodes. */
struct {
uint8_t di_v2_pad[6]; /* V2 inode zeroed space */
uint16_t di_flushiter; /* V2 inode incremented on flush */
};
};
xfs_log_timestamp_t di_atime; /* time last accessed */ xfs_log_timestamp_t di_atime; /* time last accessed */
xfs_log_timestamp_t di_mtime; /* time last modified */ xfs_log_timestamp_t di_mtime; /* time last modified */
xfs_log_timestamp_t di_ctime; /* time created/inode modified */ xfs_log_timestamp_t di_ctime; /* time created/inode modified */
xfs_fsize_t di_size; /* number of bytes in file */ xfs_fsize_t di_size; /* number of bytes in file */
xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */
xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
xfs_extnum_t di_nextents; /* number of extents in data fork */ union {
xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ /*
* For V2 inodes and V3 inodes without NREXT64 set, this
* is the number of data and attr fork extents.
*/
struct {
uint32_t di_nextents;
uint16_t di_anextents;
} __packed;
/* Number of attr fork extents if NREXT64 is set. */
struct {
uint32_t di_big_anextents;
uint16_t di_nrext64_pad;
} __packed;
} __packed;
uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
int8_t di_aformat; /* format of attr fork's data */ int8_t di_aformat; /* format of attr fork's data */
uint32_t di_dmevmask; /* DMIG event mask */ uint32_t di_dmevmask; /* DMIG event mask */
...@@ -869,4 +902,36 @@ struct xfs_icreate_log { ...@@ -869,4 +902,36 @@ struct xfs_icreate_log {
__be32 icl_gen; /* inode generation number to use */ __be32 icl_gen; /* inode generation number to use */
}; };
/*
* Flags for deferred attribute operations.
* Upper bits are flags, lower byte is type code
*/
#define XFS_ATTR_OP_FLAGS_SET 1 /* Set the attribute */
#define XFS_ATTR_OP_FLAGS_REMOVE 2 /* Remove the attribute */
#define XFS_ATTR_OP_FLAGS_REPLACE 3 /* Replace the attribute */
#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */
/*
* This is the structure used to lay out an attr log item in the
* log.
*/
struct xfs_attri_log_format {
uint16_t alfi_type; /* attri log item type */
uint16_t alfi_size; /* size of this item */
uint32_t __pad; /* pad to 64 bit aligned */
uint64_t alfi_id; /* attri identifier */
uint64_t alfi_ino; /* the inode for this attr operation */
uint32_t alfi_op_flags; /* marks the op as a set or remove */
uint32_t alfi_name_len; /* attr name length */
uint32_t alfi_value_len; /* attr value length */
uint32_t alfi_attr_flags;/* attr flags */
};
struct xfs_attrd_log_format {
uint16_t alfd_type; /* attrd log item type */
uint16_t alfd_size; /* size of this item */
uint32_t __pad; /* pad to 64 bit aligned */
uint64_t alfd_alf_id; /* id of corresponding attri */
};
#endif /* __XFS_LOG_FORMAT_H__ */ #endif /* __XFS_LOG_FORMAT_H__ */
...@@ -72,6 +72,8 @@ extern const struct xlog_recover_item_ops xlog_rui_item_ops; ...@@ -72,6 +72,8 @@ extern const struct xlog_recover_item_ops xlog_rui_item_ops;
extern const struct xlog_recover_item_ops xlog_rud_item_ops; extern const struct xlog_recover_item_ops xlog_rud_item_ops;
extern const struct xlog_recover_item_ops xlog_cui_item_ops; extern const struct xlog_recover_item_ops xlog_cui_item_ops;
extern const struct xlog_recover_item_ops xlog_cud_item_ops; extern const struct xlog_recover_item_ops xlog_cud_item_ops;
extern const struct xlog_recover_item_ops xlog_attri_item_ops;
extern const struct xlog_recover_item_ops xlog_attrd_item_ops;
/* /*
* Macros, structures, prototypes for internal log manager use. * Macros, structures, prototypes for internal log manager use.
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_da_btree.h" #include "xfs_da_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_trace.h"
/* /*
* Calculate the maximum length in bytes that would be required for a local * Calculate the maximum length in bytes that would be required for a local
...@@ -36,6 +37,65 @@ xfs_log_calc_max_attrsetm_res( ...@@ -36,6 +37,65 @@ xfs_log_calc_max_attrsetm_res(
M_RES(mp)->tr_attrsetrt.tr_logres * nblks; M_RES(mp)->tr_attrsetrt.tr_logres * nblks;
} }
/*
* Compute an alternate set of log reservation sizes for use exclusively with
* minimum log size calculations.
*/
static void
xfs_log_calc_trans_resv_for_minlogblocks(
struct xfs_mount *mp,
struct xfs_trans_resv *resv)
{
unsigned int rmap_maxlevels = mp->m_rmap_maxlevels;
/*
* In the early days of rmap+reflink, we always set the rmap maxlevels
* to 9 even if the AG was small enough that it would never grow to
* that height. Transaction reservation sizes influence the minimum
* log size calculation, which influences the size of the log that mkfs
* creates. Use the old value here to ensure that newly formatted
* small filesystems will mount on older kernels.
*/
if (xfs_has_rmapbt(mp) && xfs_has_reflink(mp))
mp->m_rmap_maxlevels = XFS_OLD_REFLINK_RMAP_MAXLEVELS;
xfs_trans_resv_calc(mp, resv);
if (xfs_has_reflink(mp)) {
/*
* In the early days of reflink, typical log operation counts
* were greatly overestimated.
*/
resv->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
resv->tr_itruncate.tr_logcount =
XFS_ITRUNCATE_LOG_COUNT_REFLINK;
resv->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
} else if (xfs_has_rmapbt(mp)) {
/*
* In the early days of non-reflink rmap, the impact of rmapbt
* updates on log counts were not taken into account at all.
*/
resv->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
resv->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
resv->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
}
/*
* In the early days of reflink, we did not use deferred refcount
* update log items, so log reservations must be recomputed using the
* old calculations.
*/
resv->tr_write.tr_logres =
xfs_calc_write_reservation_minlogsize(mp);
resv->tr_itruncate.tr_logres =
xfs_calc_itruncate_reservation_minlogsize(mp);
resv->tr_qm_dqalloc.tr_logres =
xfs_calc_qm_dqalloc_reservation_minlogsize(mp);
/* Put everything back the way it was. This goes at the end. */
mp->m_rmap_maxlevels = rmap_maxlevels;
}
/* /*
* Iterate over the log space reservation table to figure out and return * Iterate over the log space reservation table to figure out and return
* the maximum one in terms of the pre-calculated values which were done * the maximum one in terms of the pre-calculated values which were done
...@@ -46,19 +106,25 @@ xfs_log_get_max_trans_res( ...@@ -46,19 +106,25 @@ xfs_log_get_max_trans_res(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans_res *max_resp) struct xfs_trans_res *max_resp)
{ {
struct xfs_trans_resv resv = {};
struct xfs_trans_res *resp; struct xfs_trans_res *resp;
struct xfs_trans_res *end_resp; struct xfs_trans_res *end_resp;
unsigned int i;
int log_space = 0; int log_space = 0;
int attr_space; int attr_space;
attr_space = xfs_log_calc_max_attrsetm_res(mp); attr_space = xfs_log_calc_max_attrsetm_res(mp);
resp = (struct xfs_trans_res *)M_RES(mp); xfs_log_calc_trans_resv_for_minlogblocks(mp, &resv);
end_resp = (struct xfs_trans_res *)(M_RES(mp) + 1);
for (; resp < end_resp; resp++) { resp = (struct xfs_trans_res *)&resv;
end_resp = (struct xfs_trans_res *)(&resv + 1);
for (i = 0; resp < end_resp; i++, resp++) {
int tmp = resp->tr_logcount > 1 ? int tmp = resp->tr_logcount > 1 ?
resp->tr_logres * resp->tr_logcount : resp->tr_logres * resp->tr_logcount :
resp->tr_logres; resp->tr_logres;
trace_xfs_trans_resv_calc_minlogsize(mp, i, resp);
if (log_space < tmp) { if (log_space < tmp) {
log_space = tmp; log_space = tmp;
*max_resp = *resp; /* struct copy */ *max_resp = *resp; /* struct copy */
...@@ -66,9 +132,10 @@ xfs_log_get_max_trans_res( ...@@ -66,9 +132,10 @@ xfs_log_get_max_trans_res(
} }
if (attr_space > log_space) { if (attr_space > log_space) {
*max_resp = M_RES(mp)->tr_attrsetm; /* struct copy */ *max_resp = resv.tr_attrsetm; /* struct copy */
max_resp->tr_logres = attr_space; max_resp->tr_logres = attr_space;
} }
trace_xfs_log_get_max_trans_res(mp, max_resp);
} }
/* /*
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* and quota-limits. This is a waste in the common case, but hey ... * and quota-limits. This is a waste in the common case, but hey ...
*/ */
typedef uint64_t xfs_qcnt_t; typedef uint64_t xfs_qcnt_t;
typedef uint16_t xfs_qwarncnt_t;
typedef uint8_t xfs_dqtype_t; typedef uint8_t xfs_dqtype_t;
...@@ -29,8 +28,8 @@ typedef uint8_t xfs_dqtype_t; ...@@ -29,8 +28,8 @@ typedef uint8_t xfs_dqtype_t;
/* /*
* flags for q_flags field in the dquot. * flags for q_flags field in the dquot.
*/ */
#define XFS_DQFLAG_DIRTY (1 << 0) /* dquot is dirty */ #define XFS_DQFLAG_DIRTY (1u << 0) /* dquot is dirty */
#define XFS_DQFLAG_FREEING (1 << 1) /* dquot is being torn down */ #define XFS_DQFLAG_FREEING (1u << 1) /* dquot is being torn down */
#define XFS_DQFLAG_STRINGS \ #define XFS_DQFLAG_STRINGS \
{ XFS_DQFLAG_DIRTY, "DIRTY" }, \ { XFS_DQFLAG_DIRTY, "DIRTY" }, \
...@@ -73,29 +72,45 @@ typedef uint8_t xfs_dqtype_t; ...@@ -73,29 +72,45 @@ typedef uint8_t xfs_dqtype_t;
* to a single function. None of these XFS_QMOPT_* flags are meant to have * to a single function. None of these XFS_QMOPT_* flags are meant to have
* persistent values (ie. their values can and will change between versions) * persistent values (ie. their values can and will change between versions)
*/ */
#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ #define XFS_QMOPT_UQUOTA (1u << 0) /* user dquot requested */
#define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */ #define XFS_QMOPT_GQUOTA (1u << 1) /* group dquot requested */
#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ #define XFS_QMOPT_PQUOTA (1u << 2) /* project dquot requested */
#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ #define XFS_QMOPT_FORCE_RES (1u << 3) /* ignore quota limits */
#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ #define XFS_QMOPT_SBVERSION (1u << 4) /* change superblock version num */
/* /*
* flags to xfs_trans_mod_dquot to indicate which field needs to be * flags to xfs_trans_mod_dquot to indicate which field needs to be
* modified. * modified.
*/ */
#define XFS_QMOPT_RES_REGBLKS 0x0010000 #define XFS_QMOPT_RES_REGBLKS (1u << 7)
#define XFS_QMOPT_RES_RTBLKS 0x0020000 #define XFS_QMOPT_RES_RTBLKS (1u << 8)
#define XFS_QMOPT_BCOUNT 0x0040000 #define XFS_QMOPT_BCOUNT (1u << 9)
#define XFS_QMOPT_ICOUNT 0x0080000 #define XFS_QMOPT_ICOUNT (1u << 10)
#define XFS_QMOPT_RTBCOUNT 0x0100000 #define XFS_QMOPT_RTBCOUNT (1u << 11)
#define XFS_QMOPT_DELBCOUNT 0x0200000 #define XFS_QMOPT_DELBCOUNT (1u << 12)
#define XFS_QMOPT_DELRTBCOUNT 0x0400000 #define XFS_QMOPT_DELRTBCOUNT (1u << 13)
#define XFS_QMOPT_RES_INOS 0x0800000 #define XFS_QMOPT_RES_INOS (1u << 14)
/* /*
* flags for dqalloc. * flags for dqalloc.
*/ */
#define XFS_QMOPT_INHERIT 0x1000000 #define XFS_QMOPT_INHERIT (1u << 31)
#define XFS_QMOPT_FLAGS \
{ XFS_QMOPT_UQUOTA, "UQUOTA" }, \
{ XFS_QMOPT_PQUOTA, "PQUOTA" }, \
{ XFS_QMOPT_FORCE_RES, "FORCE_RES" }, \
{ XFS_QMOPT_SBVERSION, "SBVERSION" }, \
{ XFS_QMOPT_GQUOTA, "GQUOTA" }, \
{ XFS_QMOPT_INHERIT, "INHERIT" }, \
{ XFS_QMOPT_RES_REGBLKS, "RES_REGBLKS" }, \
{ XFS_QMOPT_RES_RTBLKS, "RES_RTBLKS" }, \
{ XFS_QMOPT_BCOUNT, "BCOUNT" }, \
{ XFS_QMOPT_ICOUNT, "ICOUNT" }, \
{ XFS_QMOPT_RTBCOUNT, "RTBCOUNT" }, \
{ XFS_QMOPT_DELBCOUNT, "DELBCOUNT" }, \
{ XFS_QMOPT_DELRTBCOUNT, "DELRTBCOUNT" }, \
{ XFS_QMOPT_RES_INOS, "RES_INOS" }
/* /*
* flags to xfs_trans_mod_dquot. * flags to xfs_trans_mod_dquot.
...@@ -114,6 +129,7 @@ typedef uint8_t xfs_dqtype_t; ...@@ -114,6 +129,7 @@ typedef uint8_t xfs_dqtype_t;
(XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA) (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp, extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
struct xfs_disk_dquot *ddq, xfs_dqid_t id); struct xfs_disk_dquot *ddq, xfs_dqid_t id);
extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp, extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
......
...@@ -886,8 +886,13 @@ xfs_refcount_still_have_space( ...@@ -886,8 +886,13 @@ xfs_refcount_still_have_space(
{ {
unsigned long overhead; unsigned long overhead;
overhead = cur->bc_ag.refc.shape_changes * /*
xfs_allocfree_log_count(cur->bc_mp, 1); * Worst case estimate: full splits of the free space and rmap btrees
* to handle each of the shape changes to the refcount btree.
*/
overhead = xfs_allocfree_block_count(cur->bc_mp,
cur->bc_ag.refc.shape_changes);
overhead += cur->bc_mp->m_refc_maxlevels;
overhead *= cur->bc_mp->m_sb.sb_blocksize; overhead *= cur->bc_mp->m_sb.sb_blocksize;
/* /*
...@@ -960,6 +965,7 @@ xfs_refcount_adjust_extents( ...@@ -960,6 +965,7 @@ xfs_refcount_adjust_extents(
* Either cover the hole (increment) or * Either cover the hole (increment) or
* delete the range (decrement). * delete the range (decrement).
*/ */
cur->bc_ag.refc.nr_ops++;
if (tmp.rc_refcount) { if (tmp.rc_refcount) {
error = xfs_refcount_insert(cur, &tmp, error = xfs_refcount_insert(cur, &tmp,
&found_tmp); &found_tmp);
...@@ -970,7 +976,6 @@ xfs_refcount_adjust_extents( ...@@ -970,7 +976,6 @@ xfs_refcount_adjust_extents(
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
cur->bc_ag.refc.nr_ops++;
} else { } else {
fsbno = XFS_AGB_TO_FSB(cur->bc_mp, fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
cur->bc_ag.pag->pag_agno, cur->bc_ag.pag->pag_agno,
...@@ -1001,11 +1006,11 @@ xfs_refcount_adjust_extents( ...@@ -1001,11 +1006,11 @@ xfs_refcount_adjust_extents(
ext.rc_refcount += adj; ext.rc_refcount += adj;
trace_xfs_refcount_modify_extent(cur->bc_mp, trace_xfs_refcount_modify_extent(cur->bc_mp,
cur->bc_ag.pag->pag_agno, &ext); cur->bc_ag.pag->pag_agno, &ext);
cur->bc_ag.refc.nr_ops++;
if (ext.rc_refcount > 1) { if (ext.rc_refcount > 1) {
error = xfs_refcount_update(cur, &ext); error = xfs_refcount_update(cur, &ext);
if (error) if (error)
goto out_error; goto out_error;
cur->bc_ag.refc.nr_ops++;
} else if (ext.rc_refcount == 1) { } else if (ext.rc_refcount == 1) {
error = xfs_refcount_delete(cur, &found_rec); error = xfs_refcount_delete(cur, &found_rec);
if (error) if (error)
...@@ -1014,7 +1019,6 @@ xfs_refcount_adjust_extents( ...@@ -1014,7 +1019,6 @@ xfs_refcount_adjust_extents(
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
cur->bc_ag.refc.nr_ops++;
goto advloop; goto advloop;
} else { } else {
fsbno = XFS_AGB_TO_FSB(cur->bc_mp, fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
......
...@@ -67,14 +67,17 @@ extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp, ...@@ -67,14 +67,17 @@ extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
* log (plus any key updates) so we'll conservatively assume 32 bytes * log (plus any key updates) so we'll conservatively assume 32 bytes
* per record. We must also leave space for btree splits on both ends * per record. We must also leave space for btree splits on both ends
* of the range and space for the CUD and a new CUI. * of the range and space for the CUD and a new CUI.
*
* Each EFI that we attach to the transaction is assumed to consume ~32 bytes.
* This is a low estimate for an EFI tracking a single extent (16 bytes for the
* EFI header, 16 for the extent, and 12 for the xlog op header), but the
* estimate is acceptable if there's more than one extent being freed.
* In the worst case of freeing every other block during a refcount decrease
* operation, we amortize the space used for one EFI log item across 16
* extents.
*/ */
#define XFS_REFCOUNT_ITEM_OVERHEAD 32 #define XFS_REFCOUNT_ITEM_OVERHEAD 32
static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res)
{
return (log_res * 3 / 4) / XFS_REFCOUNT_ITEM_OVERHEAD;
}
extern int xfs_refcount_has_record(struct xfs_btree_cur *cur, extern int xfs_refcount_has_record(struct xfs_btree_cur *cur,
xfs_agblock_t bno, xfs_extlen_t len, bool *exists); xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
union xfs_btree_rec; union xfs_btree_rec;
......
This diff is collapsed.
...@@ -122,8 +122,8 @@ int xfs_rmap_free(struct xfs_trans *tp, struct xfs_buf *agbp, ...@@ -122,8 +122,8 @@ int xfs_rmap_free(struct xfs_trans *tp, struct xfs_buf *agbp,
const struct xfs_owner_info *oinfo); const struct xfs_owner_info *oinfo);
int xfs_rmap_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno, int xfs_rmap_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_extlen_t len, uint64_t owner, uint64_t offset, uint64_t owner, uint64_t offset, unsigned int flags,
unsigned int flags, int *stat); struct xfs_rmap_irec *irec, int *stat);
int xfs_rmap_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno, int xfs_rmap_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_extlen_t len, uint64_t owner, uint64_t offset, xfs_extlen_t len, uint64_t owner, uint64_t offset,
unsigned int flags, int *stat); unsigned int flags, int *stat);
...@@ -184,9 +184,6 @@ int xfs_rmap_finish_one(struct xfs_trans *tp, enum xfs_rmap_intent_type type, ...@@ -184,9 +184,6 @@ int xfs_rmap_finish_one(struct xfs_trans *tp, enum xfs_rmap_intent_type type,
xfs_fsblock_t startblock, xfs_filblks_t blockcount, xfs_fsblock_t startblock, xfs_filblks_t blockcount,
xfs_exntst_t state, struct xfs_btree_cur **pcur); xfs_exntst_t state, struct xfs_btree_cur **pcur);
int xfs_rmap_find_left_neighbor(struct xfs_btree_cur *cur, xfs_agblock_t bno,
uint64_t owner, uint64_t offset, unsigned int flags,
struct xfs_rmap_irec *irec, int *stat);
int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno, int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno,
uint64_t owner, uint64_t offset, unsigned int flags, uint64_t owner, uint64_t offset, unsigned int flags,
struct xfs_rmap_irec *irec, int *stat); struct xfs_rmap_irec *irec, int *stat);
......
...@@ -1008,6 +1008,7 @@ xfs_rtfree_extent( ...@@ -1008,6 +1008,7 @@ xfs_rtfree_extent(
/* Find all the free records within a given range. */ /* Find all the free records within a given range. */
int int
xfs_rtalloc_query_range( xfs_rtalloc_query_range(
struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
const struct xfs_rtalloc_rec *low_rec, const struct xfs_rtalloc_rec *low_rec,
const struct xfs_rtalloc_rec *high_rec, const struct xfs_rtalloc_rec *high_rec,
...@@ -1015,7 +1016,6 @@ xfs_rtalloc_query_range( ...@@ -1015,7 +1016,6 @@ xfs_rtalloc_query_range(
void *priv) void *priv)
{ {
struct xfs_rtalloc_rec rec; struct xfs_rtalloc_rec rec;
struct xfs_mount *mp = tp->t_mountp;
xfs_rtblock_t rtstart; xfs_rtblock_t rtstart;
xfs_rtblock_t rtend; xfs_rtblock_t rtend;
xfs_rtblock_t high_key; xfs_rtblock_t high_key;
...@@ -1048,7 +1048,7 @@ xfs_rtalloc_query_range( ...@@ -1048,7 +1048,7 @@ xfs_rtalloc_query_range(
rec.ar_startext = rtstart; rec.ar_startext = rtstart;
rec.ar_extcount = rtend - rtstart + 1; rec.ar_extcount = rtend - rtstart + 1;
error = fn(tp, &rec, priv); error = fn(mp, tp, &rec, priv);
if (error) if (error)
break; break;
} }
...@@ -1062,6 +1062,7 @@ xfs_rtalloc_query_range( ...@@ -1062,6 +1062,7 @@ xfs_rtalloc_query_range(
/* Find all the free records. */ /* Find all the free records. */
int int
xfs_rtalloc_query_all( xfs_rtalloc_query_all(
struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_rtalloc_query_range_fn fn, xfs_rtalloc_query_range_fn fn,
void *priv) void *priv)
...@@ -1069,10 +1070,10 @@ xfs_rtalloc_query_all( ...@@ -1069,10 +1070,10 @@ xfs_rtalloc_query_all(
struct xfs_rtalloc_rec keys[2]; struct xfs_rtalloc_rec keys[2];
keys[0].ar_startext = 0; keys[0].ar_startext = 0;
keys[1].ar_startext = tp->t_mountp->m_sb.sb_rextents - 1; keys[1].ar_startext = mp->m_sb.sb_rextents - 1;
keys[0].ar_extcount = keys[1].ar_extcount = 0; keys[0].ar_extcount = keys[1].ar_extcount = 0;
return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv); return xfs_rtalloc_query_range(mp, tp, &keys[0], &keys[1], fn, priv);
} }
/* Is the given extent all free? */ /* Is the given extent all free? */
......
This diff is collapsed.
...@@ -54,13 +54,23 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, ...@@ -54,13 +54,23 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp,
/* /*
* Values for t_flags. * Values for t_flags.
*/ */
#define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */ /* Transaction needs to be logged */
#define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */ #define XFS_TRANS_DIRTY (1u << 0)
#define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */ /* Superblock is dirty and needs to be logged */
#define XFS_TRANS_SYNC 0x08 /* make commit synchronous */ #define XFS_TRANS_SB_DIRTY (1u << 1)
#define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */ /* Transaction took a permanent log reservation */
#define XFS_TRANS_NO_WRITECOUNT 0x40 /* do not elevate SB writecount */ #define XFS_TRANS_PERM_LOG_RES (1u << 2)
#define XFS_TRANS_RES_FDBLKS 0x80 /* reserve newly freed blocks */ /* Synchronous transaction commit needed */
#define XFS_TRANS_SYNC (1u << 3)
/* Transaction can use reserve block pool */
#define XFS_TRANS_RESERVE (1u << 4)
/* Transaction should avoid VFS level superblock write accounting */
#define XFS_TRANS_NO_WRITECOUNT (1u << 5)
/* Transaction has freed blocks returned to it's reservation */
#define XFS_TRANS_RES_FDBLKS (1u << 6)
/* Transaction contains an intent done log item */
#define XFS_TRANS_HAS_INTENT_DONE (1u << 7)
/* /*
* LOWMODE is used by the allocator to activate the lowspace algorithm - when * LOWMODE is used by the allocator to activate the lowspace algorithm - when
* free space is running low the extent allocator may choose to allocate an * free space is running low the extent allocator may choose to allocate an
......
This diff is collapsed.
...@@ -73,7 +73,6 @@ struct xfs_trans_resv { ...@@ -73,7 +73,6 @@ struct xfs_trans_resv {
#define XFS_DEFAULT_LOG_COUNT 1 #define XFS_DEFAULT_LOG_COUNT 1
#define XFS_DEFAULT_PERM_LOG_COUNT 2 #define XFS_DEFAULT_PERM_LOG_COUNT 2
#define XFS_ITRUNCATE_LOG_COUNT 2 #define XFS_ITRUNCATE_LOG_COUNT 2
#define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8
#define XFS_INACTIVE_LOG_COUNT 2 #define XFS_INACTIVE_LOG_COUNT 2
#define XFS_CREATE_LOG_COUNT 2 #define XFS_CREATE_LOG_COUNT 2
#define XFS_CREATE_TMPFILE_LOG_COUNT 2 #define XFS_CREATE_TMPFILE_LOG_COUNT 2
...@@ -83,13 +82,24 @@ struct xfs_trans_resv { ...@@ -83,13 +82,24 @@ struct xfs_trans_resv {
#define XFS_LINK_LOG_COUNT 2 #define XFS_LINK_LOG_COUNT 2
#define XFS_RENAME_LOG_COUNT 2 #define XFS_RENAME_LOG_COUNT 2
#define XFS_WRITE_LOG_COUNT 2 #define XFS_WRITE_LOG_COUNT 2
#define XFS_WRITE_LOG_COUNT_REFLINK 8
#define XFS_ADDAFORK_LOG_COUNT 2 #define XFS_ADDAFORK_LOG_COUNT 2
#define XFS_ATTRINVAL_LOG_COUNT 1 #define XFS_ATTRINVAL_LOG_COUNT 1
#define XFS_ATTRSET_LOG_COUNT 3 #define XFS_ATTRSET_LOG_COUNT 3
#define XFS_ATTRRM_LOG_COUNT 3 #define XFS_ATTRRM_LOG_COUNT 3
/*
* Original log operation counts were overestimated in the early days of
* reflink. These are retained here purely for minimum log size calculations
* and must not be used for runtime reservations.
*/
#define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8
#define XFS_WRITE_LOG_COUNT_REFLINK 8
void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp); void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
uint xfs_allocfree_log_count(struct xfs_mount *mp, uint num_ops); uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops);
unsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *mp);
unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp);
unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *mp);
#endif /* __XFS_TRANS_RESV_H__ */ #endif /* __XFS_TRANS_RESV_H__ */
This diff is collapsed.
This diff is collapsed.
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "xfs_rmap_btree.h" #include "xfs_rmap_btree.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_reflink.h" #include "xfs_reflink.h"
#include "xfs_ag.h" #include "xfs_ag.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_attr_sf.h" #include "xfs_attr_sf.h"
#include "xfs_attr_leaf.h" #include "xfs_attr_leaf.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment