diff options
author | Bob Peterson <rpeterso@redhat.com> | 2017-01-30 11:51:21 -0500 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2017-01-30 12:10:25 -0500 |
commit | aacee72061a352d52ef9d3854f8db3b86b93ea16 (patch) | |
tree | 2c8cdb53631c6576663c7a1d2a7c285c7d425cb8 | |
parent | 192738b711d3e41a7326347db5d6923d2136b6d0 (diff) |
GFS2: Reduce contention on gfs2_log_lock
This patch modifies functions gfs2_trans_add_meta and _data so that
they check whether the buffer_head is already in a transaction,
and if so, avoid taking the gfs2_log_lock.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r-- | fs/gfs2/trans.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 483c5a7e16d4..affef3c066e0 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c | |||
@@ -170,6 +170,10 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) | |||
170 | } | 170 | } |
171 | 171 | ||
172 | lock_buffer(bh); | 172 | lock_buffer(bh); |
173 | if (buffer_pinned(bh)) { | ||
174 | set_bit(TR_TOUCHED, &tr->tr_flags); | ||
175 | goto out; | ||
176 | } | ||
173 | gfs2_log_lock(sdp); | 177 | gfs2_log_lock(sdp); |
174 | bd = bh->b_private; | 178 | bd = bh->b_private; |
175 | if (bd == NULL) { | 179 | if (bd == NULL) { |
@@ -192,6 +196,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) | |||
192 | list_add_tail(&bd->bd_list, &tr->tr_databuf); | 196 | list_add_tail(&bd->bd_list, &tr->tr_databuf); |
193 | } | 197 | } |
194 | gfs2_log_unlock(sdp); | 198 | gfs2_log_unlock(sdp); |
199 | out: | ||
195 | unlock_buffer(bh); | 200 | unlock_buffer(bh); |
196 | } | 201 | } |
197 | 202 | ||
@@ -201,10 +206,14 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) | |||
201 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; | 206 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
202 | struct gfs2_bufdata *bd; | 207 | struct gfs2_bufdata *bd; |
203 | struct gfs2_meta_header *mh; | 208 | struct gfs2_meta_header *mh; |
204 | struct gfs2_trans *tr; | 209 | struct gfs2_trans *tr = current->journal_info; |
205 | enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); | 210 | enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); |
206 | 211 | ||
207 | lock_buffer(bh); | 212 | lock_buffer(bh); |
213 | if (buffer_pinned(bh)) { | ||
214 | set_bit(TR_TOUCHED, &tr->tr_flags); | ||
215 | goto out; | ||
216 | } | ||
208 | gfs2_log_lock(sdp); | 217 | gfs2_log_lock(sdp); |
209 | bd = bh->b_private; | 218 | bd = bh->b_private; |
210 | if (bd == NULL) { | 219 | if (bd == NULL) { |
@@ -220,7 +229,6 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) | |||
220 | gfs2_log_lock(sdp); | 229 | gfs2_log_lock(sdp); |
221 | } | 230 | } |
222 | gfs2_assert(sdp, bd->bd_gl == gl); | 231 | gfs2_assert(sdp, bd->bd_gl == gl); |
223 | tr = current->journal_info; | ||
224 | set_bit(TR_TOUCHED, &tr->tr_flags); | 232 | set_bit(TR_TOUCHED, &tr->tr_flags); |
225 | if (!list_empty(&bd->bd_list)) | 233 | if (!list_empty(&bd->bd_list)) |
226 | goto out_unlock; | 234 | goto out_unlock; |
@@ -243,6 +251,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) | |||
243 | tr->tr_num_buf_new++; | 251 | tr->tr_num_buf_new++; |
244 | out_unlock: | 252 | out_unlock: |
245 | gfs2_log_unlock(sdp); | 253 | gfs2_log_unlock(sdp); |
254 | out: | ||
246 | unlock_buffer(bh); | 255 | unlock_buffer(bh); |
247 | } | 256 | } |
248 | 257 | ||