aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_log.c95
1 files changed, 48 insertions, 47 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 99c62855432e..9a4b9edad847 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -98,53 +98,34 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
98STATIC int xlog_iclogs_empty(xlog_t *log); 98STATIC int xlog_iclogs_empty(xlog_t *log);
99 99
100static void 100static void
101xlog_grant_sub_space(struct log *log, int bytes) 101xlog_grant_sub_space(
102{ 102 struct log *log,
103 log->l_grant_write_bytes -= bytes; 103 int *cycle,
104 if (log->l_grant_write_bytes < 0) { 104 int *space,
105 log->l_grant_write_bytes += log->l_logsize; 105 int bytes)
106 log->l_grant_write_cycle--;
107 }
108
109 log->l_grant_reserve_bytes -= bytes;
110 if ((log)->l_grant_reserve_bytes < 0) {
111 log->l_grant_reserve_bytes += log->l_logsize;
112 log->l_grant_reserve_cycle--;
113 }
114
115}
116
117static void
118xlog_grant_add_space_write(struct log *log, int bytes)
119{ 106{
120 int tmp = log->l_logsize - log->l_grant_write_bytes; 107 *space -= bytes;
121 if (tmp > bytes) 108 if (*space < 0) {
122 log->l_grant_write_bytes += bytes; 109 *space += log->l_logsize;
123 else { 110 (*cycle)--;
124 log->l_grant_write_cycle++;
125 log->l_grant_write_bytes = bytes - tmp;
126 } 111 }
127} 112}
128 113
129static void 114static void
130xlog_grant_add_space_reserve(struct log *log, int bytes) 115xlog_grant_add_space(
116 struct log *log,
117 int *cycle,
118 int *space,
119 int bytes)
131{ 120{
132 int tmp = log->l_logsize - log->l_grant_reserve_bytes; 121 int tmp = log->l_logsize - *space;
133 if (tmp > bytes) 122 if (tmp > bytes)
134 log->l_grant_reserve_bytes += bytes; 123 *space += bytes;
135 else { 124 else {
136 log->l_grant_reserve_cycle++; 125 *space = bytes - tmp;
137 log->l_grant_reserve_bytes = bytes - tmp; 126 (*cycle)++;
138 } 127 }
139} 128}
140
141static inline void
142xlog_grant_add_space(struct log *log, int bytes)
143{
144 xlog_grant_add_space_write(log, bytes);
145 xlog_grant_add_space_reserve(log, bytes);
146}
147
148static void 129static void
149xlog_tic_reset_res(xlog_ticket_t *tic) 130xlog_tic_reset_res(xlog_ticket_t *tic)
150{ 131{
@@ -1344,7 +1325,10 @@ xlog_sync(xlog_t *log,
1344 1325
1345 /* move grant heads by roundoff in sync */ 1326 /* move grant heads by roundoff in sync */
1346 spin_lock(&log->l_grant_lock); 1327 spin_lock(&log->l_grant_lock);
1347 xlog_grant_add_space(log, roundoff); 1328 xlog_grant_add_space(log, &log->l_grant_reserve_cycle,
1329 &log->l_grant_reserve_bytes, roundoff);
1330 xlog_grant_add_space(log, &log->l_grant_write_cycle,
1331 &log->l_grant_write_bytes, roundoff);
1348 spin_unlock(&log->l_grant_lock); 1332 spin_unlock(&log->l_grant_lock);
1349 1333
1350 /* put cycle number in every block */ 1334 /* put cycle number in every block */
@@ -2574,7 +2558,10 @@ redo:
2574 list_del_init(&tic->t_queue); 2558 list_del_init(&tic->t_queue);
2575 2559
2576 /* we've got enough space */ 2560 /* we've got enough space */
2577 xlog_grant_add_space(log, need_bytes); 2561 xlog_grant_add_space(log, &log->l_grant_reserve_cycle,
2562 &log->l_grant_reserve_bytes, need_bytes);
2563 xlog_grant_add_space(log, &log->l_grant_write_cycle,
2564 &log->l_grant_write_bytes, need_bytes);
2578 trace_xfs_log_grant_exit(log, tic); 2565 trace_xfs_log_grant_exit(log, tic);
2579 xlog_verify_grant_head(log, 1); 2566 xlog_verify_grant_head(log, 1);
2580 xlog_verify_grant_tail(log); 2567 xlog_verify_grant_tail(log);
@@ -2701,7 +2688,8 @@ redo:
2701 list_del_init(&tic->t_queue); 2688 list_del_init(&tic->t_queue);
2702 2689
2703 /* we've got enough space */ 2690 /* we've got enough space */
2704 xlog_grant_add_space_write(log, need_bytes); 2691 xlog_grant_add_space(log, &log->l_grant_write_cycle,
2692 &log->l_grant_write_bytes, need_bytes);
2705 trace_xfs_log_regrant_write_exit(log, tic); 2693 trace_xfs_log_regrant_write_exit(log, tic);
2706 xlog_verify_grant_head(log, 1); 2694 xlog_verify_grant_head(log, 1);
2707 xlog_verify_grant_tail(log); 2695 xlog_verify_grant_tail(log);
@@ -2742,7 +2730,12 @@ xlog_regrant_reserve_log_space(xlog_t *log,
2742 ticket->t_cnt--; 2730 ticket->t_cnt--;
2743 2731
2744 spin_lock(&log->l_grant_lock); 2732 spin_lock(&log->l_grant_lock);
2745 xlog_grant_sub_space(log, ticket->t_curr_res); 2733 xlog_grant_sub_space(log, &log->l_grant_reserve_cycle,
2734 &log->l_grant_reserve_bytes,
2735 ticket->t_curr_res);
2736 xlog_grant_sub_space(log, &log->l_grant_write_cycle,
2737 &log->l_grant_write_bytes,
2738 ticket->t_curr_res);
2746 ticket->t_curr_res = ticket->t_unit_res; 2739 ticket->t_curr_res = ticket->t_unit_res;
2747 xlog_tic_reset_res(ticket); 2740 xlog_tic_reset_res(ticket);
2748 2741
@@ -2756,7 +2749,9 @@ xlog_regrant_reserve_log_space(xlog_t *log,
2756 return; 2749 return;
2757 } 2750 }
2758 2751
2759 xlog_grant_add_space_reserve(log, ticket->t_unit_res); 2752 xlog_grant_add_space(log, &log->l_grant_reserve_cycle,
2753 &log->l_grant_reserve_bytes,
2754 ticket->t_unit_res);
2760 2755
2761 trace_xfs_log_regrant_reserve_exit(log, ticket); 2756 trace_xfs_log_regrant_reserve_exit(log, ticket);
2762 2757
@@ -2785,24 +2780,30 @@ STATIC void
2785xlog_ungrant_log_space(xlog_t *log, 2780xlog_ungrant_log_space(xlog_t *log,
2786 xlog_ticket_t *ticket) 2781 xlog_ticket_t *ticket)
2787{ 2782{
2783 int bytes;
2784
2788 if (ticket->t_cnt > 0) 2785 if (ticket->t_cnt > 0)
2789 ticket->t_cnt--; 2786 ticket->t_cnt--;
2790 2787
2791 spin_lock(&log->l_grant_lock); 2788 spin_lock(&log->l_grant_lock);
2792 trace_xfs_log_ungrant_enter(log, ticket); 2789 trace_xfs_log_ungrant_enter(log, ticket);
2793
2794 xlog_grant_sub_space(log, ticket->t_curr_res);
2795
2796 trace_xfs_log_ungrant_sub(log, ticket); 2790 trace_xfs_log_ungrant_sub(log, ticket);
2797 2791
2798 /* If this is a permanent reservation ticket, we may be able to free 2792 /*
2793 * If this is a permanent reservation ticket, we may be able to free
2799 * up more space based on the remaining count. 2794 * up more space based on the remaining count.
2800 */ 2795 */
2796 bytes = ticket->t_curr_res;
2801 if (ticket->t_cnt > 0) { 2797 if (ticket->t_cnt > 0) {
2802 ASSERT(ticket->t_flags & XLOG_TIC_PERM_RESERV); 2798 ASSERT(ticket->t_flags & XLOG_TIC_PERM_RESERV);
2803 xlog_grant_sub_space(log, ticket->t_unit_res*ticket->t_cnt); 2799 bytes += ticket->t_unit_res*ticket->t_cnt;
2804 } 2800 }
2805 2801
2802 xlog_grant_sub_space(log, &log->l_grant_reserve_cycle,
2803 &log->l_grant_reserve_bytes, bytes);
2804 xlog_grant_sub_space(log, &log->l_grant_write_cycle,
2805 &log->l_grant_write_bytes, bytes);
2806
2806 trace_xfs_log_ungrant_exit(log, ticket); 2807 trace_xfs_log_ungrant_exit(log, ticket);
2807 2808
2808 xlog_verify_grant_head(log, 1); 2809 xlog_verify_grant_head(log, 1);