xfsprogs: code sync up for log space reservation
PATCH 1/1 xfsprogs: code sync up for log space reservation
Hello,
Here is a patch to sync up the kernel code changes regarding log space reservation to the xfsprogs.
There have a couple of differences between the kernel and the user space.
1) A few transaction reservation item related to dquot are not synced because they are not being used in xfsprogs.
2) In xfs_log_rlimit.c, the xfs_log_validate_logspace() is not copied and the xfs_mkfs.c still use the default validate_log_space() to check the given log size.
Thanks,
-Jeff
From: Jie Liu <[email protected]>
Sync up the kernel space code changes to the user space which are includes:
1) Sync up xfs_log_rlimit.[c|h] to libxfs and replaced two functions at mkfs/maxres.c for figuring out the max transaction reservation.
2) Add m_tresp() helper, libxfs_trans_reserve() interface refactor and propagate them to where they should be.
--- include/libxfs.h | 9 ++- include/xfs_log_rlimit.h | 24 ++++++ include/xfs_mount.h | 72 ++++++++++------- libxfs/Makefile | 2 +- libxfs/trans.c | 10 +-- libxfs/util.c | 11 ++- libxfs/xfs_attr.c | 44 +++++------ libxfs/xfs_bmap.c | 4 +- libxfs/xfs_log_rlimit.c | 73 ++++++++++++++++++ libxfs/xfs_trans.c | 109 +++++++++++++++++++------- mkfs/maxtrres.c | 68 ++++------------ mkfs/proto.c | 61 +++++++++------ mkfs/xfs_mkfs.c | 9 ++- repair/phase6.c | 193 ++++++++++++++++++++++++---------------------- repair/phase7.c | 6 +- 15 files changed, 424 insertions(+), 271 deletions(-) create mode 100644 include/xfs_log_rlimit.h create mode 100644 libxfs/xfs_log_rlimit.c
include/libxfs.h +8 -1
@@ -55,6 +55,7 @@#include <xfs/xfs_btree.h> #include <xfs/xfs_btree_trace.h> #include <xfs/xfs_bmap.h> +#include <xfs/xfs_log_rlimit.h> #include <xfs/xfs_trace.h> #ifndef ARRAY_SIZE
@@ -197,6 +198,11 @@ typedef struct xfs_mount {xfs_dablk_t m_dirfreeblk;/* blockno of dirfreeindex v2 */ } xfs_mount_t; +static inline struct xfs_trans_reservations * +m_tresp (struct xfs_mount *mp) +{ +return &mp->m_reservations; +}#define LIBXFS_MOUNT_ROOTINOS 0x0001#define LIBXFS_MOUNT_DEBUGGER 0x0002
@@ -429,7 +435,8 @@ typedef struct xfs_trans {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 (xfs_trans_t *,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 void libxfs_mod_sb (xfs_trans_t *,__int64_t );
include/xfs_log_rlimit.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2013 Jie Liu. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef __XFS_LOG_RLIMIT_H__ +#define __XFS_LOG_RLIMIT_H__ + +void xfs_log_adjust_max_attrsetm_res (struct xfs_mount *); +void xfs_log_get_max_trans_res (struct xfs_mount *,struct xfs_trans_res *); + +#endif /* __XFS_LOG_PRIV_H__ */
include/xfs_mount.h +44 -28
81 lines not on this page · raw message
libxfs/Makefile +1 -1
@@ -16,7 +16,7 @@ CFILES = cache.c init.c kmem.c logitem.c radix-tree.c rdwr.c trans.c util.c \ xfs_ialloc_btree.c xfs_bmap_btree.c xfs_da_btree.c \ xfs_dir2.c xfs_dir2_leaf.c xfs_attr_leaf.c xfs_dir2_block.c \ xfs_dir2_node.c xfs_dir2_data.c xfs_dir2_sf.c xfs_bmap.c \ - xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c \ + xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c xfs_log_rlimit.c \ crc32.c CFILES += $(PKG_PLATFORM).c
libxfs/trans.c +4 -6
@@ -58,12 +58,10 @@ libxfs_trans_dup(int libxfs_trans_reserve ( -xfs_trans_t *tp, -uint blocks, -uint logspace, -uint rtextents, -uint flags, -uint logcount) +xfs_trans_t *tp, +struct xfs_trans_res *tres, +uint blocks, +uint rtextents) {xfs_sb_t *mpsb = &tp->t_mountp->m_sb;
libxfs/util.c +9 -2
@@ -442,11 +442,14 @@ libxfs_alloc_file_space(/* allocate file space until done or until there is an error */ while (allocatesize_fsb && !error) { +struct xfs_trans_res tres; + datablocks = allocatesize_fsb; 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 ); +memset (&tres,0 ,sizeof (tres)); + error =xfs_trans_reserve (tp, &tres, resblks,0 );if (error)break ;xfs_trans_ijoin (tp, ip,0 );
@@ -528,11 +531,15 @@ libxfs_inode_alloc( }if (ialloc_context) { +struct xfs_trans_res tres; +xfs_trans_bhold (*tp, ialloc_context); ntp =xfs_trans_dup (*tp);xfs_trans_commit (*tp,0 ); *tp = ntp; -if ((i =xfs_trans_reserve (*tp,0 ,0 ,0 ,0 ,0 ))) { +memset (&tres,0 ,sizeof (tres)); + i =xfs_trans_reserve (*tp, &tres,0 ,0 ); +if (i) {fprintf (stderr,_ ("%s: cannot reserve space: %s\n" ), progname,strerror (i));exit (1 );
libxfs/xfs_attr.c +21 -23
63 lines not on this page · raw message
libxfs/xfs_bmap.c +2 -2
@@ -1290,8 +1290,8 @@ xfs_bmap_add_attrfork( 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_tresp (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 ?
libxfs/xfs_log_rlimit.c new file +73 -0
73 lines not on this page · raw message
libxfs/xfs_trans.c +79 -30
139 lines not on this page · raw message
mkfs/maxtrres.c +13 -55
84 lines not on this page · raw message
mkfs/proto.c +37 -24
101 lines not on this page · raw message
mkfs/xfs_mkfs.c +6 -3
@@ -2685,8 +2685,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),* BNO, CNT free block list */ for (agno =0 ; agno < agcount; agno++) { -xfs_alloc_arg_t args; -xfs_trans_t *tp; +struct xfs_alloc_arg args; +struct xfs_trans *tp; +struct xfs_trans_res tres;memset (&args,0 ,sizeof (args)); args.tp = tp =libxfs_trans_alloc (mp,0 );
@@ -2694,7 +2695,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), 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 ))) +memset (&tres,0 ,sizeof (tres)); + 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);
repair/phase6.c +101 -92
329 lines not on this page · raw message
repair/phase7.c +2 -4
@@ -71,10 +71,8 @@ update_inode_nlinks( 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 ); - + error =libxfs_trans_reserve (tp, &m_tresp (mp)->tr_remove, + (no_modify ?0 :10 ),0 );ASSERT (error ==0 ); error =libxfs_trans_iget (mp, tp, ino,0 ,0 , &ip);
Signature · 6 lines
1.7.9.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Jeff Liu
Hello,
Here is a patch to sync up the kernel code changes regarding log space reservation to the xfsprogs.
There have a couple of differences between the kernel and the user space.
1) A few transaction reservation item related to dquot are not synced because they are not being used in xfsprogs.
2) Inxfs_log_rlimit.c, thexfs_log_validate_logspace()is not copied and thexfs_mkfs.cstill use the defaultvalidate_log_space()to check the given log size.
Hi Jeff,
Just as a heads up, this is going to have conflicts with the CRC patchset that I'm planning on posting in a few minutes. How do you want to resolve them?
Quoted 1 line
From my perspective it's easier if we rebase your patch on top of my
patchset. If we go the other way around, I'll have to rebase 10-20 patches that your patch has conflicts with....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Hi Dave,
Quoted 14 lines · Dave Chinner
Quoted 10 lines · Jeff Liu
Hello,
Here is a patch to sync up the kernel code changes regarding log space reservation to the xfsprogs.
There have a couple of differences between the kernel and the user space.
1) A few transaction reservation item related to dquot are not synced because they are not being used in xfsprogs.
2) Inxfs_log_rlimit.c, thexfs_log_validate_logspace()is not copied and thexfs_mkfs.cstill use the defaultvalidate_log_space()to check the given log size.Hi Jeff,
Quoted 7 lines
Just as a heads up, this is going to have conflicts with the CRC patchset that I'm planning on posting in a few minutes. How do you want to resolve them?
From my perspective it's easier if we rebase your patch on top of my patchset. If we go the other way around, I'll have to rebase 10-20 patches that your patch has conflicts with....
Sure. It's ok to me since I only need to rebase one big patch. :)
Thanks,
-Jeff
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs