Skip to content

Commit 614abc1

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fold qd_fish into gfs2_quota_sync
The split between qd_fish() and gfs2_quota_sync() is rather unfortunate as qd_fish() is repeatedly called to scan sdp->sd_quota_list only to find the next object to that needs syncing; if there are multiple objects on the list that need syncing, it makes more sense to grab them all in one go. This is relatively easy to do when qd_fish() is folded into gfs2_quota_sync(). Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent b510af0 commit 614abc1

File tree

1 file changed

+29
-48
lines changed

1 file changed

+29
-48
lines changed

fs/gfs2/quota.c

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -484,40 +484,6 @@ static void qd_ungrab_sync(struct gfs2_quota_data *qd)
484484
qd_put(qd);
485485
}
486486

487-
static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
488-
{
489-
struct gfs2_quota_data *qd = NULL, *iter;
490-
int error;
491-
492-
*qdp = NULL;
493-
494-
if (sb_rdonly(sdp->sd_vfs))
495-
return 0;
496-
497-
spin_lock(&qd_lock);
498-
499-
list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) {
500-
if (qd_grab_sync(sdp, iter, sdp->sd_quota_sync_gen)) {
501-
qd = iter;
502-
break;
503-
}
504-
}
505-
506-
spin_unlock(&qd_lock);
507-
508-
if (qd) {
509-
error = bh_get(qd);
510-
if (error) {
511-
qd_ungrab_sync(qd);
512-
return error;
513-
}
514-
}
515-
516-
*qdp = qd;
517-
518-
return 0;
519-
}
520-
521487
static void qdsb_put(struct gfs2_quota_data *qd)
522488
{
523489
bh_put(qd);
@@ -1332,10 +1298,10 @@ int gfs2_quota_sync(struct super_block *sb, int type)
13321298
struct gfs2_sbd *sdp = sb->s_fs_info;
13331299
struct gfs2_quota_data **qda;
13341300
unsigned int max_qd = PAGE_SIZE / sizeof(struct gfs2_holder);
1335-
unsigned int num_qd;
1336-
unsigned int x;
13371301
int error = 0;
13381302

1303+
if (sb_rdonly(sdp->sd_vfs))
1304+
return 0;
13391305
if (!qd_changed(sdp))
13401306
return 0;
13411307

@@ -1347,24 +1313,39 @@ int gfs2_quota_sync(struct super_block *sb, int type)
13471313
sdp->sd_quota_sync_gen++;
13481314

13491315
do {
1350-
num_qd = 0;
1316+
struct gfs2_quota_data *iter;
1317+
unsigned int num_qd = 0;
1318+
unsigned int x;
13511319

1352-
for (;;) {
1353-
error = qd_fish(sdp, qda + num_qd);
1354-
if (error || !qda[num_qd])
1355-
break;
1356-
if (++num_qd == max_qd)
1357-
break;
1320+
spin_lock(&qd_lock);
1321+
list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) {
1322+
if (qd_grab_sync(sdp, iter, sdp->sd_quota_sync_gen)) {
1323+
qda[num_qd++] = iter;
1324+
if (num_qd == max_qd)
1325+
break;
1326+
}
13581327
}
1328+
spin_unlock(&qd_lock);
13591329

1360-
if (num_qd) {
1330+
if (!num_qd)
1331+
break;
1332+
1333+
for (x = 0; x < num_qd; x++) {
1334+
error = bh_get(qda[x]);
13611335
if (!error)
1362-
error = do_sync(num_qd, qda);
1336+
continue;
13631337

1364-
for (x = 0; x < num_qd; x++)
1365-
qd_unlock(qda[x]);
1338+
while (x < num_qd)
1339+
qd_ungrab_sync(qda[--num_qd]);
1340+
break;
13661341
}
1367-
} while (!error && num_qd == max_qd);
1342+
1343+
if (!error)
1344+
error = do_sync(num_qd, qda);
1345+
1346+
for (x = 0; x < num_qd; x++)
1347+
qd_unlock(qda[x]);
1348+
} while (!error);
13681349

13691350
mutex_unlock(&sdp->sd_quota_sync_mutex);
13701351
kfree(qda);

0 commit comments

Comments
 (0)