xfs_log_item_t ili_item; /* common portion */
struct xfs_inode *ili_inode; /* inode pointer */
unsigned short ili_flags; /* misc flags */
+ unsigned short ili_lock_flags; /* lock flags */
unsigned int ili_fields; /* fields to be logged */
unsigned int ili_last_fields; /* fields when flushed*/
} xfs_inode_log_item_t;
struct xfs_defer_ops {
struct list_head dop_intake; /* unlogged pending work */
struct list_head dop_pending; /* logged pending work */
-
- /* relog these with each roll */
- struct xfs_inode *dop_inodes[XFS_DEFER_OPS_NR_INODES];
};
typedef struct xfs_trans {
#define xfs_zero_extent libxfs_zero_extent
#define xfs_defer_init libxfs_defer_init
-#define xfs_defer_ijoin libxfs_defer_ijoin
#define xfs_defer_finish libxfs_defer_finish
#define xfs_defer_cancel libxfs_defer_cancel
ASSERT(iip->ili_flags == 0);
ASSERT(iip->ili_inode != NULL);
+ ASSERT(iip->ili_lock_flags == 0);
+ iip->ili_lock_flags = lock_flags;
+
xfs_trans_add_item(tp, (xfs_log_item_t *)(iip));
ip->i_transp = tp;
* buffer and run into problems with the write verifier.
*/
xfs_trans_bhold(args.trans, leaf_bp);
- xfs_defer_ijoin(args.trans->t_dfops, dp);
error = xfs_defer_finish(&args.trans);
if (error)
goto out;
error = xfs_attr3_leaf_to_node(args);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
/* bp is gone due to xfs_da_shrink_inode */
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
/* bp is gone due to xfs_da_shrink_inode */
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
error = xfs_attr3_leaf_to_node(args);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
error = xfs_da3_split(state);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
error = xfs_da3_join(state);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
error = xfs_da3_join(state);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
/* bp is gone due to xfs_da_shrink_inode */
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
&nmap);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
XFS_BMAPI_ATTRFORK, 1, &done);
if (error)
goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, args->dp);
error = xfs_defer_finish(&args->trans);
if (error)
goto out_defer_cancel;
xfs_log_sb(tp);
}
- xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
int whichfork,
struct xfs_bmbt_irec *bmap)
{
- int error;
struct xfs_bmap_intent *bi;
trace_xfs_bmap_defer(mp,
bi->bi_whichfork = whichfork;
bi->bi_bmap = *bmap;
- error = xfs_defer_ijoin(dfops, bi->bi_owner);
- if (error) {
- kmem_free(bi);
- return error;
- }
-
xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list);
return 0;
}
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_trans.h"
+#include "xfs_inode.h"
#include "xfs_trace.h"
/*
{
struct xfs_defer_ops *dop = (*tp)->t_dfops;
struct xfs_buf_log_item *bli;
+ struct xfs_inode_log_item *ili;
struct xfs_log_item *lip;
struct xfs_buf *bplist[XFS_DEFER_OPS_NR_BUFS];
- int bpcount = 0;
+ struct xfs_inode *iplist[XFS_DEFER_OPS_NR_INODES];
+ int bpcount = 0, ipcount = 0;
int i;
int error;
- /* Log all the joined inodes. */
- for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++)
- xfs_trans_log_inode(*tp, dop->dop_inodes[i], XFS_ILOG_CORE);
-
list_for_each_entry(lip, &(*tp)->t_items, li_trans) {
switch (lip->li_type) {
case XFS_LI_BUF:
bplist[bpcount++] = bli->bli_buf;
}
break;
+ case XFS_LI_INODE:
+ ili = container_of(lip, struct xfs_inode_log_item,
+ ili_item);
+ if (ili->ili_lock_flags == 0) {
+ if (ipcount >= XFS_DEFER_OPS_NR_INODES) {
+ ASSERT(0);
+ return -EFSCORRUPTED;
+ }
+ xfs_trans_log_inode(*tp, ili->ili_inode,
+ XFS_ILOG_CORE);
+ iplist[ipcount++] = ili->ili_inode;
+ }
+ break;
default:
break;
}
}
/* Rejoin the joined inodes. */
- for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++)
- xfs_trans_ijoin(*tp, dop->dop_inodes[i], 0);
+ for (i = 0; i < ipcount; i++)
+ xfs_trans_ijoin(*tp, iplist[i], 0);
/* Rejoin the buffers and dirty them so the log moves forward. */
for (i = 0; i < bpcount; i++) {
return !list_empty(&dop->dop_pending) || !list_empty(&dop->dop_intake);
}
-/*
- * Add this inode to the deferred op. Each joined inode is relogged
- * each time we roll the transaction.
- */
-int
-xfs_defer_ijoin(
- struct xfs_defer_ops *dop,
- struct xfs_inode *ip)
-{
- int i;
-
- for (i = 0; i < XFS_DEFER_OPS_NR_INODES; i++) {
- if (dop->dop_inodes[i] == ip)
- return 0;
- else if (dop->dop_inodes[i] == NULL) {
- dop->dop_inodes[i] = ip;
- return 0;
- }
- }
-
- ASSERT(0);
- return -EFSCORRUPTED;
-}
-
/*
* Reset an already used dfops after finish.
*/
xfs_defer_reset(
struct xfs_trans *tp)
{
- struct xfs_defer_ops *dop = tp->t_dfops;
-
- ASSERT(!xfs_defer_has_unfinished_work(dop));
-
- memset(dop->dop_inodes, 0, sizeof(dop->dop_inodes));
+ ASSERT(!xfs_defer_has_unfinished_work(tp->t_dfops));
/*
* Low mode state transfers across transaction rolls to mirror dfops
list_splice_init(&src->dop_intake, &dst->dop_intake);
list_splice_init(&src->dop_pending, &dst->dop_pending);
- memcpy(dst->dop_inodes, src->dop_inodes, sizeof(dst->dop_inodes));
-
/*
* Low free space mode was historically controlled by a dfops field.
* This meant that low mode state potentially carried across multiple
void xfs_defer_cancel(struct xfs_trans *);
void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
-int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
/* Description of a deferred type. */
char *buf;
int error;
int flags;
- struct xfs_defer_ops dfops;
int fmt;
int i;
xfs_inode_t *ip;
xname.type = XFS_DIR3_FT_REG_FILE;
newdirent(mp, tp, pip, &xname, ip->i_ino);
libxfs_trans_log_inode(tp, ip, flags);
-
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
rsvfile(mp, ip, llen);
IRELE(ip);
}
newdirectory(mp, tp, ip, pip);
libxfs_trans_log_inode(tp, ip, flags);
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
/*
* RT initialization. Do this here to ensure that
fail(_("Unknown format"), EINVAL);
}
libxfs_trans_log_inode(tp, ip, flags);
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
IRELE(ip);
}
xfs_fileoff_t ebno;
xfs_bmbt_irec_t *ep;
int error;
- struct xfs_defer_ops dfops;
int i;
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
xfs_extlen_t nsumblocks;
}
}
- libxfs_defer_ijoin(&dfops, rbmip);
libxfs_trans_commit(tp);
/*
bno += ep->br_blockcount;
}
}
- libxfs_defer_ijoin(&dfops, rsumip);
libxfs_trans_commit(tp);
/*
fail(_("Error initializing the realtime space"),
error);
}
- libxfs_defer_ijoin(&dfops, rbmip);
libxfs_trans_commit(tp);
}
}
int i;
int nmap;
int error;
- struct xfs_defer_ops dfops;
xfs_fileoff_t bno;
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
int vers;
bno += ep->br_blockcount;
}
}
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
IRELE(ip);
}
int nmap;
int error;
int nsumblocks;
- struct xfs_defer_ops dfops;
xfs_fileoff_t bno;
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
int vers;
bno += ep->br_blockcount;
}
}
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
IRELE(ip);
}
int ino_offset = 0;
int i;
int error;
- struct xfs_defer_ops dfops;
const int mode = 0755;
int nres;
struct xfs_name xname;
libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE);
libxfs_dir_init(tp, ip, pip);
libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
-
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
IRELE(ip);
IRELE(pip);
xfs_ino_t entry_ino_num;
xfs_inode_t *ino_p;
xfs_trans_t *tp;
- struct xfs_defer_ops dfops;
int err;
unsigned char fname[MAXPATHLEN + 1];
int nres;
inc_nlink(VFS_I(ino_p));
libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE);
-
- libxfs_defer_ijoin(&dfops, ino_p);
libxfs_trans_commit(tp);
} else {
err = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_rename,
err);
}
- libxfs_defer_ijoin(&dfops, ino_p);
libxfs_trans_commit(tp);
}
set_nlink(VFS_I(ino_p), 1);
libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE);
-
- libxfs_defer_ijoin(&dfops, ino_p);
libxfs_trans_commit(tp);
}
IRELE(ino_p);
int nres;
xfs_trans_t *tp;
xfs_fileoff_t lastblock;
- struct xfs_defer_ops dfops;
xfs_inode_t pip;
dir_hash_ent_t *p;
int done;
goto out_bmap_cancel;
}
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
if (ino == mp->m_sb.sb_rootino)
goto out_bmap_cancel;
}
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
}
{
xfs_da_args_t args;
int error;
- struct xfs_defer_ops dfops;
int nres;
xfs_trans_t *tp;
if (error)
do_error(_("shrink_inode failed inode %" PRIu64 " block %u\n"),
ip->i_ino, da_bno);
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
}
struct xfs_dir2_data_free *bf;
char *endptr;
int error;
- struct xfs_defer_ops dfops;
char fname[MAXNAMELEN + 1];
freetab_t *freetab;
int i;
d, &i);
if (needlog)
libxfs_dir2_data_log_header(&da, bp);
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
/* record the largest free space in the freetab for later checking */
int ino_offset)
{
xfs_ino_t ino;
- struct xfs_defer_ops dfops;
xfs_inode_t *ip;
xfs_trans_t *tp;
dir_hash_tab_t *hashtab;
_("can't make \"..\" entry in root inode %" PRIu64 ", createname error %d\n"), ino, error);
libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
-
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
need_root_dotdot = 0;
ino, error);
libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
-
- libxfs_defer_ijoin(&dfops, ip);
libxfs_trans_commit(tp);
}
}