extern xfs_trans_t *libxfs_trans_alloc (xfs_mount_t *, int);
extern xfs_trans_t *libxfs_trans_dup (xfs_trans_t *);
-extern int libxfs_trans_reserve (xfs_trans_t *, uint,uint,uint,uint,uint);
+extern int libxfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *,
+ uint, uint);
extern int libxfs_trans_commit (xfs_trans_t *, uint);
extern void libxfs_trans_cancel (xfs_trans_t *, int);
extern xfs_buf_t *libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int);
struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
};
+/* shorthand way of accessing reservation structure */
+#define M_RES(mp) (&(mp)->m_resv)
+
/*
* Per-extent log reservation for the allocation btree changes
* involved in freeing or allocating an extent.
struct xfs_inode *dp)
{
struct xfs_trans *trans;
- unsigned int logres, count;
+ struct xfs_trans_res tres;
int error;
/*
/*
* Copy the critical parameters from one trans to the next.
*/
- logres = trans->t_log_res;
- count = trans->t_log_count;
+ tres.tr_logres = trans->t_log_res;
+ tres.tr_logcount = trans->t_log_count;
*tpp = xfs_trans_dup(trans);
/*
* across this call, or that anything that is locked be logged in
* the prior and the next transactions.
*/
- error = xfs_trans_reserve(trans, 0, logres, 0,
- XFS_TRANS_PERM_LOG_RES, count);
+ tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+ error = xfs_trans_reserve(trans, &tres, 0, 0);
/*
* Ensure that the inode is in the new transaction and locked.
*/
int
libxfs_trans_reserve(
- xfs_trans_t *tp,
- uint blocks,
- uint logspace,
- uint rtextents,
- uint flags,
- uint logcount)
+ struct xfs_trans *tp,
+ struct xfs_trans_res *resp,
+ uint blocks,
+ uint rtextents)
{
xfs_sb_t *mpsb = &tp->t_mountp->m_sb;
tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
resblks = (uint)XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
- error = xfs_trans_reserve(tp, resblks, 0, 0, 0, 0);
+ error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
+ resblks, 0);
if (error)
break;
xfs_trans_ijoin(tp, ip, 0);
struct fsxattr *fsx,
xfs_inode_t **ipp)
{
- int i;
xfs_buf_t *ialloc_context;
xfs_inode_t *ip;
xfs_trans_t *ntp;
}
if (ialloc_context) {
+ struct xfs_trans_res tres;
+
xfs_trans_bhold(*tp, ialloc_context);
+ tres.tr_logres = (*tp)->t_log_res;
+ tres.tr_logcount = (*tp)->t_log_count;
+
ntp = xfs_trans_dup(*tp);
xfs_trans_commit(*tp, 0);
*tp = ntp;
- if ((i = xfs_trans_reserve(*tp, 0, 0, 0, 0, 0))) {
+ tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+ error = xfs_trans_reserve(*tp, &tres, 0, 0);
+ if (error) {
fprintf(stderr, _("%s: cannot reserve space: %s\n"),
- progname, strerror(i));
+ progname, strerror(error));
exit(1);
}
xfs_trans_bjoin(*tp, ialloc_context);
int valuelen,
int flags)
{
- xfs_da_args_t args;
- xfs_fsblock_t firstblock;
- xfs_bmap_free_t flist;
- int error, err2, committed;
- xfs_mount_t *mp = dp->i_mount;
- int rsvd = (flags & ATTR_ROOT) != 0;
- int local;
+ xfs_da_args_t args;
+ xfs_fsblock_t firstblock;
+ xfs_bmap_free_t flist;
+ int error, err2, committed;
+ struct xfs_mount *mp = dp->i_mount;
+ struct xfs_trans_res tres;
+ int rsvd = (flags & ATTR_ROOT) != 0;
+ int local;
/*
* Attach the dquots to the inode.
if (rsvd)
args.trans->t_flags |= XFS_TRANS_RESERVE;
- error = xfs_trans_reserve(args.trans, args.total,
- XFS_ATTRSETM_LOG_RES(mp) +
- XFS_ATTRSETRT_LOG_RES(mp) * args.total,
- 0, XFS_TRANS_PERM_LOG_RES,
- XFS_ATTRSET_LOG_COUNT);
+ tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres +
+ M_RES(mp)->tr_attrsetrt.tr_logres * args.total;
+ tres.tr_logcount = XFS_ATTRSET_LOG_COUNT;
+ tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+ error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
if (error) {
xfs_trans_cancel(args.trans, 0);
return(error);
if (flags & ATTR_ROOT)
args.trans->t_flags |= XFS_TRANS_RESERVE;
- if ((error = xfs_trans_reserve(args.trans,
- XFS_ATTRRM_SPACE_RES(mp),
- XFS_ATTRRM_LOG_RES(mp),
- 0, XFS_TRANS_PERM_LOG_RES,
- XFS_ATTRRM_LOG_COUNT))) {
+ error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
+ XFS_ATTRRM_SPACE_RES(mp), 0);
+ if (error) {
xfs_trans_cancel(args.trans, 0);
return(error);
}
blks = XFS_ADDAFORK_SPACE_RES(mp);
if (rsvd)
tp->t_flags |= XFS_TRANS_RESERVE;
- if ((error = xfs_trans_reserve(tp, blks, XFS_ADDAFORK_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT)))
+ error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
+ if (error)
goto error0;
xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
* Since the runtime attribute transaction space is dependent on the total
* blocks needed for the 1st bmap, here we calculate out the space unit for
* one block so that the caller could figure out the total space according
- * to the attibute extent length in blocks by: ext * XFS_ATTRSETRT_LOG_RES(mp).
+ * to the attibute extent length in blocks by:
+ * ext * M_RES(mp)->tr_attrsetrt.tr_logres
*/
STATIC uint
xfs_calc_attrsetrt_reservation(
/*
* Allocating quota on disk if needed.
- * the write transaction log space: XFS_WRITE_LOG_RES(mp)
+ * the write transaction log space: M_RES(mp)->tr_write.tr_logres
* the unit of quota allocation: one system block size
*/
STATIC uint
xfs_calc_qm_dqalloc_reservation(
struct xfs_mount *mp)
{
- return XFS_WRITE_LOG_RES(mp) +
+ return M_RES(mp)->tr_write.tr_logres +
xfs_calc_buf_res(1,
XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
}
mp = tp->t_mountp;
for (i = 0, r = MKFS_BLOCKRES(blocks); r >= blocks; r--) {
- i = libxfs_trans_reserve(tp, r, 0, 0, 0, 0);
+ struct xfs_trans_res tres = {0};
+
+ i = libxfs_trans_reserve(tp, &tres, r, 0);
if (i == 0)
return;
}
xfs_trans_t *tp;
struct cred creds;
struct fsxattr fsxattrs;
+ struct xfs_trans_res tres = {0};
/*
* First, allocate the inodes.
*/
tp = libxfs_trans_alloc(mp, 0);
- if ((i = libxfs_trans_reserve(tp, MKFS_BLOCKRES_INODE, 0, 0, 0, 0)))
+ i = libxfs_trans_reserve(tp, &tres, MKFS_BLOCKRES_INODE, 0);
+ if (i)
res_failed(i);
+
memset(&creds, 0, sizeof(creds));
memset(&fsxattrs, 0, sizeof(fsxattrs));
error = libxfs_inode_alloc(&tp, NULL, S_IFREG, 1, 0,
* Next, give the bitmap file some zero-filled blocks.
*/
tp = libxfs_trans_alloc(mp, 0);
- if ((i = libxfs_trans_reserve(tp, mp->m_sb.sb_rbmblocks +
- (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0, 0, 0, 0)))
+ i = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+ (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+ if (i)
res_failed(i);
+
libxfs_trans_ijoin(tp, rbmip, 0);
libxfs_trans_ihold(tp, rbmip);
bno = 0;
*/
tp = libxfs_trans_alloc(mp, 0);
nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
- if ((i = libxfs_trans_reserve(tp,
- nsumblocks + (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1),
- 0, 0, 0, 0)))
+ i = libxfs_trans_reserve(tp, &tres, nsumblocks +
+ (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+ if (i)
res_failed(i);
libxfs_trans_ijoin(tp, rsumip, 0);
libxfs_trans_ihold(tp, rsumip);
*/
for (bno = 0; bno < mp->m_sb.sb_rextents; bno = ebno) {
tp = libxfs_trans_alloc(mp, 0);
- if ((i = libxfs_trans_reserve(tp, 0, 0, 0, 0, 0)))
+ i = libxfs_trans_reserve(tp, &tres, 0, 0);
+ if (i)
res_failed(i);
libxfs_trans_ijoin(tp, rbmip, 0);
libxfs_trans_ihold(tp, rbmip);
for (agno = 0; agno < agcount; agno++) {
xfs_alloc_arg_t args;
xfs_trans_t *tp;
+ struct xfs_trans_res tres = {0};
memset(&args, 0, sizeof(args));
args.tp = tp = libxfs_trans_alloc(mp, 0);
args.agno = agno;
args.alignment = 1;
args.pag = xfs_perag_get(mp,agno);
- if ((c = libxfs_trans_reserve(tp, worst_freelist, 0, 0, 0, 0)))
+ c = libxfs_trans_reserve(tp, &tres, worst_freelist, 0);
+ if (c)
res_failed(c);
+
libxfs_alloc_fix_freelist(&args, 0);
xfs_perag_put(args.pag);
libxfs_trans_commit(tp, 0);
{
xfs_alloc_arg_t args;
xfs_trans_t *tp;
+ struct xfs_trans_res tres = {0};
memset(&args, 0, sizeof(args));
args.tp = tp = libxfs_trans_alloc(mp, 0);
args.agno = agno;
args.alignment = 1;
args.pag = xfs_perag_get(mp,agno);
- libxfs_trans_reserve(tp, XFS_MIN_FREELIST(agf, mp), 0, 0, 0, 0);
+ libxfs_trans_reserve(tp, &tres, XFS_MIN_FREELIST(agf, mp), 0);
libxfs_alloc_fix_freelist(&args, 0);
xfs_perag_put(args.pag);
libxfs_trans_commit(tp, 0);
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
int vers;
int times;
+ struct xfs_trans_res tres = {0};
/*
* first set up inode
*/
tp = libxfs_trans_alloc(mp, 0);
- if ((i = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+ i = libxfs_trans_reserve(tp, &tres, 10, 0);
+ if (i)
res_failed(i);
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 0, &ip);
* from mkfs)
*/
tp = libxfs_trans_alloc(mp, 0);
- if ((error = libxfs_trans_reserve(tp, mp->m_sb.sb_rbmblocks +
- (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0, 0, 0, 0)))
+ error = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+ (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+ if (error)
res_failed(error);
libxfs_trans_ijoin(tp, ip, 0);
int error;
xfs_dfiloff_t bno;
xfs_bmbt_irec_t map;
+ struct xfs_trans_res tres = {0};
bmp = btmcompute;
bno = 0;
tp = libxfs_trans_alloc(mp, 0);
- if ((error = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+ error = libxfs_trans_reserve(tp, &tres, 10, 0);
+ if (error)
res_failed(error);
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 0, &ip);
xfs_dfiloff_t bno;
xfs_dfiloff_t end_bno;
xfs_bmbt_irec_t map;
+ struct xfs_trans_res tres = {0};
smp = sumcompute;
bno = 0;
tp = libxfs_trans_alloc(mp, 0);
- if ((error = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+ error = libxfs_trans_reserve(tp, &tres, 10, 0);
+ if (error)
res_failed(error);
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 0, &ip);
xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
int vers;
int times;
+ struct xfs_trans_res tres = {0};
/*
* first set up inode
*/
tp = libxfs_trans_alloc(mp, 0);
- if ((i = libxfs_trans_reserve(tp, 10, XFS_ICHANGE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+ i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+ if (i)
res_failed(i);
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 0, &ip);
xfs_bmap_init(&flist, &first);
nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
- if ((error = libxfs_trans_reserve(tp,
- mp->m_sb.sb_rbmblocks +
- (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1),
- BBTOB(128), 0, XFS_TRANS_PERM_LOG_RES,
- XFS_DEFAULT_PERM_LOG_COUNT)))
+ tres.tr_logres = BBTOB(128);
+ tres.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
+ tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+ error = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+ (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+ if (error)
res_failed(error);
libxfs_trans_ijoin(tp, ip, 0);
tp = libxfs_trans_alloc(mp, 0);
ip = NULL;
- if ((i = libxfs_trans_reserve(tp, 10, XFS_ICHANGE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+ i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+ if (i)
res_failed(i);
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rootino, 0, 0, &ip);
xfs_bmap_init(&flist, &first);
nres = XFS_MKDIR_SPACE_RES(mp, xname.len);
- if ((i = libxfs_trans_reserve(tp, nres, XFS_MKDIR_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+ i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
+ if (i)
res_failed(i);
/*
if (err) {
ASSERT(err == ENOENT);
- if ((err = libxfs_trans_reserve(tp, nres,
- XFS_RENAME_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES,
- XFS_RENAME_LOG_COUNT)))
+ err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
+ nres, 0);
+ if (err)
do_error(
_("space reservation failed (%d), filesystem may be out of space\n"),
err);
libxfs_trans_commit(tp,
XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC);
} else {
- if ((err = libxfs_trans_reserve(tp, nres,
- XFS_RENAME_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES,
- XFS_RENAME_LOG_COUNT)))
+ err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
+ nres, 0);
+ if (err)
do_error(
_("space reservation failed (%d), filesystem may be out of space\n"),
err);
* also accounted for in the create
*/
nres = XFS_DIRENTER_SPACE_RES(mp, xname.len);
- err = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+ err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
+ nres, 0);
if (err)
do_error(
_("space reservation failed (%d), filesystem may be out of space\n"),
tp = libxfs_trans_alloc(mp, 0);
nres = XFS_REMOVE_SPACE_RES(mp);
- error = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
if (error)
res_failed(error);
libxfs_trans_ijoin(tp, ip, 0);
tp = libxfs_trans_alloc(mp, 0);
nres = XFS_CREATE_SPACE_RES(mp, p->name.len);
- error = libxfs_trans_reserve(tp, nres, XFS_CREATE_LOG_RES(mp),
- 0, XFS_TRANS_PERM_LOG_RES, XFS_CREATE_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_create,
+ nres, 0);
if (error) {
do_warn(
_("space reservation failed (%d), filesystem may be out of space\n"),
tp = libxfs_trans_alloc(mp, 0);
nres = XFS_REMOVE_SPACE_RES(mp);
- error = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
if (error)
res_failed(error);
libxfs_trans_ijoin(tp, ip, 0);
freetab->nents = db + 1;
tp = libxfs_trans_alloc(mp, 0);
- error = libxfs_trans_reserve(tp, 0, XFS_REMOVE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
if (error)
res_failed(error);
libxfs_trans_ijoin(tp, ip, 0);
* new define in ourselves.
*/
nres = no_modify ? 0 : XFS_REMOVE_SPACE_RES(mp);
- error = libxfs_trans_reserve(tp, nres,
- XFS_REMOVE_LOG_RES(mp), 0,
- XFS_TRANS_PERM_LOG_RES,
- XFS_REMOVE_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
+ nres, 0);
if (error)
res_failed(error);
ASSERT(tp != NULL);
nres = XFS_MKDIR_SPACE_RES(mp, 2);
- error = libxfs_trans_reserve(tp, nres, XFS_MKDIR_LOG_RES(mp),
- 0, XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT);
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
if (error)
res_failed(error);
ASSERT(tp != NULL);
nres = XFS_MKDIR_SPACE_RES(mp, 1);
- error = libxfs_trans_reserve(tp, nres,
- XFS_MKDIR_LOG_RES(mp),
- 0,
- XFS_TRANS_PERM_LOG_RES,
- XFS_MKDIR_LOG_COUNT);
-
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir,
+ nres, 0);
if (error)
res_failed(error);
xfs_inode_t *ip;
int error;
int dirty;
+ int nres;
tp = libxfs_trans_alloc(mp, XFS_TRANS_REMOVE);
- error = libxfs_trans_reserve(tp, (no_modify ? 0 : 10),
- XFS_REMOVE_LOG_RES(mp), 0, XFS_TRANS_PERM_LOG_RES,
- XFS_REMOVE_LOG_COUNT);
-
+ nres = no_modify ? 0 : 10;
+ error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
ASSERT(error == 0);
error = libxfs_trans_iget(mp, tp, ino, 0, 0, &ip);