aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorJie Liu <jeff.liu@oracle.com>2013-08-12 06:49:56 -0400
committerBen Myers <bpm@sgi.com>2013-08-12 18:45:49 -0400
commit0eadd1028858b193ce8cdc36bf443d39b42141ca (patch)
tree22f1624807ae9a75cc7adaf16a607e1f88ac0dd8 /fs/xfs
parent9356fe22af084e7b9c1f3c8633a1cbe9b36de405 (diff)
xfs: Introduce a new structure to hold transaction reservation items
Introduce a new structure xfs_trans_res to hold transaction reservation item info per log ticket. We also need to improve xfs_trans_resv_calc() by initializing the log count as well as log flags for permanent log reservation. Signed-off-by: Jie Liu <jeff.liu@oracle.com> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_mount.h2
-rw-r--r--fs/xfs/xfs_trans.c2
-rw-r--r--fs/xfs/xfs_trans_resv.c121
-rw-r--r--fs/xfs/xfs_trans_resv.h125
4 files changed, 163 insertions, 87 deletions
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 829035f615aa..1fa0584b5627 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -136,7 +136,7 @@ typedef struct xfs_mount {
136 int m_ialloc_blks; /* blocks in inode allocation */ 136 int m_ialloc_blks; /* blocks in inode allocation */
137 int m_inoalign_mask;/* mask sb_inoalignmt if used */ 137 int m_inoalign_mask;/* mask sb_inoalignmt if used */
138 uint m_qflags; /* quota status flags */ 138 uint m_qflags; /* quota status flags */
139 struct xfs_trans_resv m_reservations; /* precomputed res values */ 139 struct xfs_trans_resv m_resv; /* precomputed res values */
140 __uint64_t m_maxicount; /* maximum inode count */ 140 __uint64_t m_maxicount; /* maximum inode count */
141 __uint64_t m_resblks; /* total reserved blocks */ 141 __uint64_t m_resblks; /* total reserved blocks */
142 __uint64_t m_resblks_avail;/* available reserved blocks */ 142 __uint64_t m_resblks_avail;/* available reserved blocks */
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index cc824effd305..e0f93f957c5c 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -56,7 +56,7 @@ void
56xfs_trans_init( 56xfs_trans_init(
57 struct xfs_mount *mp) 57 struct xfs_mount *mp)
58{ 58{
59 xfs_trans_resv_calc(mp, &mp->m_reservations); 59 xfs_trans_resv_calc(mp, &mp->m_resv);
60} 60}
61 61
62/* 62/*
diff --git a/fs/xfs/xfs_trans_resv.c b/fs/xfs/xfs_trans_resv.c
index ed6446ecb9a5..376148184373 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/xfs_trans_resv.c
@@ -671,32 +671,97 @@ xfs_trans_resv_calc(
671 struct xfs_mount *mp, 671 struct xfs_mount *mp,
672 struct xfs_trans_resv *resp) 672 struct xfs_trans_resv *resp)
673{ 673{
674 resp->tr_write = xfs_calc_write_reservation(mp); 674 /*
675 resp->tr_itruncate = xfs_calc_itruncate_reservation(mp); 675 * The following transactions are logged in physical format and
676 resp->tr_rename = xfs_calc_rename_reservation(mp); 676 * require a permanent reservation on space.
677 resp->tr_link = xfs_calc_link_reservation(mp); 677 */
678 resp->tr_remove = xfs_calc_remove_reservation(mp); 678 resp->tr_write.tr_logres = xfs_calc_write_reservation(mp);
679 resp->tr_symlink = xfs_calc_symlink_reservation(mp); 679 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
680 resp->tr_create = xfs_calc_create_reservation(mp); 680 resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
681 resp->tr_mkdir = xfs_calc_mkdir_reservation(mp); 681
682 resp->tr_ifree = xfs_calc_ifree_reservation(mp); 682 resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp);
683 resp->tr_ichange = xfs_calc_ichange_reservation(mp); 683 resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
684 resp->tr_growdata = xfs_calc_growdata_reservation(mp); 684 resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
685 resp->tr_swrite = xfs_calc_swrite_reservation(mp); 685
686 resp->tr_writeid = xfs_calc_writeid_reservation(mp); 686 resp->tr_rename.tr_logres = xfs_calc_rename_reservation(mp);
687 resp->tr_addafork = xfs_calc_addafork_reservation(mp); 687 resp->tr_rename.tr_logcount = XFS_RENAME_LOG_COUNT;
688 resp->tr_attrinval = xfs_calc_attrinval_reservation(mp); 688 resp->tr_rename.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
689 resp->tr_attrsetm = xfs_calc_attrsetm_reservation(mp); 689
690 resp->tr_attrsetrt = xfs_calc_attrsetrt_reservation(mp); 690 resp->tr_link.tr_logres = xfs_calc_link_reservation(mp);
691 resp->tr_attrrm = xfs_calc_attrrm_reservation(mp); 691 resp->tr_link.tr_logcount = XFS_LINK_LOG_COUNT;
692 resp->tr_clearagi = xfs_calc_clear_agi_bucket_reservation(mp); 692 resp->tr_link.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
693 resp->tr_growrtalloc = xfs_calc_growrtalloc_reservation(mp); 693
694 resp->tr_growrtzero = xfs_calc_growrtzero_reservation(mp); 694 resp->tr_remove.tr_logres = xfs_calc_remove_reservation(mp);
695 resp->tr_growrtfree = xfs_calc_growrtfree_reservation(mp); 695 resp->tr_remove.tr_logcount = XFS_REMOVE_LOG_COUNT;
696 resp->tr_qm_sbchange = xfs_calc_qm_sbchange_reservation(mp); 696 resp->tr_remove.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
697 resp->tr_qm_setqlim = xfs_calc_qm_setqlim_reservation(mp); 697
698 resp->tr_qm_dqalloc = xfs_calc_qm_dqalloc_reservation(mp); 698 resp->tr_symlink.tr_logres = xfs_calc_symlink_reservation(mp);
699 resp->tr_qm_quotaoff = xfs_calc_qm_quotaoff_reservation(mp); 699 resp->tr_symlink.tr_logcount = XFS_SYMLINK_LOG_COUNT;
700 resp->tr_qm_equotaoff = xfs_calc_qm_quotaoff_end_reservation(mp); 700 resp->tr_symlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
701 resp->tr_sb = xfs_calc_sb_reservation(mp); 701
702 resp->tr_create.tr_logres = xfs_calc_create_reservation(mp);
703 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT;
704 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
705
706 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp);
707 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT;
708 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
709
710 resp->tr_ifree.tr_logres = xfs_calc_ifree_reservation(mp);
711 resp->tr_ifree.tr_logcount = XFS_INACTIVE_LOG_COUNT;
712 resp->tr_ifree.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
713
714 resp->tr_addafork.tr_logres = xfs_calc_addafork_reservation(mp);
715 resp->tr_addafork.tr_logcount = XFS_ADDAFORK_LOG_COUNT;
716 resp->tr_addafork.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
717
718 resp->tr_attrinval.tr_logres = xfs_calc_attrinval_reservation(mp);
719 resp->tr_attrinval.tr_logcount = XFS_ATTRINVAL_LOG_COUNT;
720 resp->tr_attrinval.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
721
722 resp->tr_attrsetm.tr_logres = xfs_calc_attrsetm_reservation(mp);
723 resp->tr_attrsetm.tr_logcount = XFS_ATTRSET_LOG_COUNT;
724 resp->tr_attrsetm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
725
726 resp->tr_attrrm.tr_logres = xfs_calc_attrrm_reservation(mp);
727 resp->tr_attrrm.tr_logcount = XFS_ATTRRM_LOG_COUNT;
728 resp->tr_attrrm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
729
730 resp->tr_growrtalloc.tr_logres = xfs_calc_growrtalloc_reservation(mp);
731 resp->tr_growrtalloc.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
732 resp->tr_growrtalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
733
734 resp->tr_qm_dqalloc.tr_logres = xfs_calc_qm_dqalloc_reservation(mp);
735 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
736 resp->tr_qm_dqalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
737
738 /*
739 * The following transactions are logged in logical format with
740 * a default log count.
741 */
742 resp->tr_qm_sbchange.tr_logres = xfs_calc_qm_sbchange_reservation(mp);
743 resp->tr_qm_sbchange.tr_logcount = XFS_DEFAULT_LOG_COUNT;
744
745 resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp);
746 resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;
747
748 resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp);
749 resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
750
751 resp->tr_qm_equotaoff.tr_logres =
752 xfs_calc_qm_quotaoff_end_reservation(mp);
753 resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
754
755 resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
756 resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT;
757
758 /* The following transaction are logged in logical format */
759 resp->tr_ichange.tr_logres = xfs_calc_ichange_reservation(mp);
760 resp->tr_growdata.tr_logres = xfs_calc_growdata_reservation(mp);
761 resp->tr_swrite.tr_logres = xfs_calc_swrite_reservation(mp);
762 resp->tr_writeid.tr_logres = xfs_calc_writeid_reservation(mp);
763 resp->tr_attrsetrt.tr_logres = xfs_calc_attrsetrt_reservation(mp);
764 resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp);
765 resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp);
766 resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp);
702} 767}
diff --git a/fs/xfs/xfs_trans_resv.h b/fs/xfs/xfs_trans_resv.h
index cc8260e6acb2..0aac1fa9b383 100644
--- a/fs/xfs/xfs_trans_resv.h
+++ b/fs/xfs/xfs_trans_resv.h
@@ -23,35 +23,45 @@ struct xfs_mount;
23/* 23/*
24 * structure for maintaining pre-calculated transaction reservations. 24 * structure for maintaining pre-calculated transaction reservations.
25 */ 25 */
26struct xfs_trans_res {
27 uint tr_logres; /* log space unit in bytes per log ticket */
28 int tr_logcount; /* number of log operations per log ticket */
29 int tr_logflags; /* log flags, currently only used for indicating
30 * a reservation request is permanent or not */
31};
32
26struct xfs_trans_resv { 33struct xfs_trans_resv {
27 uint tr_write; /* extent alloc trans */ 34 struct xfs_trans_res tr_write; /* extent alloc trans */
28 uint tr_itruncate; /* truncate trans */ 35 struct xfs_trans_res tr_itruncate; /* truncate trans */
29 uint tr_rename; /* rename trans */ 36 struct xfs_trans_res tr_rename; /* rename trans */
30 uint tr_link; /* link trans */ 37 struct xfs_trans_res tr_link; /* link trans */
31 uint tr_remove; /* unlink trans */ 38 struct xfs_trans_res tr_remove; /* unlink trans */
32 uint tr_symlink; /* symlink trans */ 39 struct xfs_trans_res tr_symlink; /* symlink trans */
33 uint tr_create; /* create trans */ 40 struct xfs_trans_res tr_create; /* create trans */
34 uint tr_mkdir; /* mkdir trans */ 41 struct xfs_trans_res tr_mkdir; /* mkdir trans */
35 uint tr_ifree; /* inode free trans */ 42 struct xfs_trans_res tr_ifree; /* inode free trans */
36 uint tr_ichange; /* inode update trans */ 43 struct xfs_trans_res tr_ichange; /* inode update trans */
37 uint tr_growdata; /* fs data section grow trans */ 44 struct xfs_trans_res tr_growdata; /* fs data section grow trans */
38 uint tr_swrite; /* sync write inode trans */ 45 struct xfs_trans_res tr_swrite; /* sync write inode trans */
39 uint tr_addafork; /* cvt inode to attributed trans */ 46 struct xfs_trans_res tr_addafork; /* add inode attr fork trans */
40 uint tr_writeid; /* write setuid/setgid file */ 47 struct xfs_trans_res tr_writeid; /* write setuid/setgid file */
41 uint tr_attrinval; /* attr fork buffer invalidation */ 48 struct xfs_trans_res tr_attrinval; /* attr fork buffer
42 uint tr_attrsetm; /* set/create an attribute at mount time */ 49 * invalidation */
43 uint tr_attrsetrt; /* set/create an attribute at runtime */ 50 struct xfs_trans_res tr_attrsetm; /* set/create an attribute at
44 uint tr_attrrm; /* remove an attribute */ 51 * mount time */
45 uint tr_clearagi; /* clear bad agi unlinked ino bucket */ 52 struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at
46 uint tr_growrtalloc; /* grow realtime allocations */ 53 * runtime */
47 uint tr_growrtzero; /* grow realtime zeroing */ 54 struct xfs_trans_res tr_attrrm; /* remove an attribute */
48 uint tr_growrtfree; /* grow realtime freeing */ 55 struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */
49 uint tr_qm_sbchange; /* change quota flags */ 56 struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */
50 uint tr_qm_setqlim; /* adjust quota limits */ 57 struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */
51 uint tr_qm_dqalloc; /* allocate quota on disk */ 58 struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
52 uint tr_qm_quotaoff; /* turn quota off */ 59 struct xfs_trans_res tr_qm_sbchange; /* change quota flags */
53 uint tr_qm_equotaoff;/* end of turn quota off */ 60 struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
54 uint tr_sb; /* modify superblock */ 61 struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
62 struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */
63 struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */
64 struct xfs_trans_res tr_sb; /* modify superblock */
55}; 65};
56 66
57/* 67/*
@@ -79,39 +89,40 @@ struct xfs_trans_resv {
79 XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) 89 XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
80 90
81 91
82#define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write) 92#define XFS_WRITE_LOG_RES(mp) ((mp)->m_resv.tr_write.tr_logres)
83#define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate) 93#define XFS_RENAME_LOG_RES(mp) ((mp)->m_resv.tr_rename.tr_logres)
84#define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename) 94#define XFS_LINK_LOG_RES(mp) ((mp)->m_resv.tr_link.tr_logres)
85#define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link) 95#define XFS_REMOVE_LOG_RES(mp) ((mp)->m_resv.tr_remove.tr_logres)
86#define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove) 96#define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_resv.tr_symlink.tr_logres)
87#define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink) 97#define XFS_CREATE_LOG_RES(mp) ((mp)->m_resv.tr_create.tr_logres)
88#define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create) 98#define XFS_MKDIR_LOG_RES(mp) ((mp)->m_resv.tr_mkdir.tr_logres)
89#define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir) 99#define XFS_IFREE_LOG_RES(mp) ((mp)->m_resv.tr_ifree.tr_logres)
90#define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree) 100#define XFS_SWRITE_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres)
91#define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange) 101#define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_resv.tr_ichange.tr_logres)
92#define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata) 102#define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_resv.tr_growdata.tr_logres)
93#define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc) 103#define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_resv.tr_itruncate.tr_logres)
94#define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero) 104#define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_resv.tr_growrtzero.tr_logres)
95#define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree) 105#define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_resv.tr_growrtfree.tr_logres)
96#define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) 106#define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_resv.tr_growrtalloc.tr_logres)
107
97/* 108/*
98 * Logging the inode timestamps on an fsync -- same as SWRITE 109 * Logging the inode timestamps on an fsync -- same as SWRITE
99 * as long as SWRITE logs the entire inode core 110 * as long as SWRITE logs the entire inode core
100 */ 111 */
101#define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) 112#define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres)
102#define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) 113#define XFS_WRITEID_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres)
103#define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork) 114#define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_resv.tr_addafork.tr_logres)
104#define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval) 115#define XFS_ATTRSETM_LOG_RES(mp) ((mp)->m_resv.tr_attrsetm.tr_logres)
105#define XFS_ATTRSETM_LOG_RES(mp) ((mp)->m_reservations.tr_attrsetm) 116#define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_resv.tr_attrinval.tr_logres)
106#define XFS_ATTRSETRT_LOG_RES(mp) ((mp)->m_reservations.tr_attrsetrt) 117#define XFS_ATTRSETRT_LOG_RES(mp) ((mp)->m_resv.tr_attrsetrt.tr_logres)
107#define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm) 118#define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_resv.tr_attrrm.tr_logres)
108#define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi) 119#define XFS_SB_LOG_RES(mp) ((mp)->m_resv.tr_sb.tr_logres)
109#define XFS_QM_SBCHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_qm_sbchange) 120#define XFS_QM_SETQLIM_LOG_RES(mp) ((mp)->m_resv.tr_qm_setqlim.tr_logres)
110#define XFS_QM_SETQLIM_LOG_RES(mp) ((mp)->m_reservations.tr_qm_setqlim) 121#define XFS_QM_DQALLOC_LOG_RES(mp) ((mp)->m_resv.tr_qm_dqalloc.tr_logres)
111#define XFS_QM_DQALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_qm_dqalloc) 122#define XFS_QM_SBCHANGE_LOG_RES(mp) ((mp)->m_resv.tr_qm_sbchange.tr_logres)
112#define XFS_QM_QUOTAOFF_LOG_RES(mp) ((mp)->m_reservations.tr_qm_quotaoff) 123#define XFS_QM_QUOTAOFF_LOG_RES(mp) ((mp)->m_resv.tr_qm_quotaoff.tr_logres)
113#define XFS_QM_QUOTAOFF_END_LOG_RES(mp) ((mp)->m_reservations.tr_qm_equotaoff) 124#define XFS_QM_QUOTAOFF_END_LOG_RES(mp) ((mp)->m_resv.tr_qm_equotaoff.tr_logres)
114#define XFS_SB_LOG_RES(mp) ((mp)->m_reservations.tr_sb) 125#define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_resv.tr_clearagi.tr_logres)
115 126
116/* 127/*
117 * Various log count values. 128 * Various log count values.