Skip to content

Commit 4fe370a

Browse files
Mark FashehJoel Becker
authored andcommitted
ocfs2: use allocation reservations during file write
Add a per-inode reservations structure and pass it through to the reservations code. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
1 parent d02f00c commit 4fe370a

6 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎fs/ocfs2/alloc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7211,6 +7211,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
72117211
goto out_commit;
72127212
did_quota = 1;
72137213

7214+
data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
7215+
72147216
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
72157217
&num);
72167218
if (ret) {

‎fs/ocfs2/aops.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,9 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
17351735
goto out;
17361736
}
17371737

1738+
if (data_ac)
1739+
data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
1740+
17381741
credits = ocfs2_calc_extend_credits(inode->i_sb,
17391742
&di->id2.i_list,
17401743
clusters_to_alloc);

‎fs/ocfs2/file.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ static int ocfs2_truncate_file(struct inode *inode,
483483

484484
down_write(&OCFS2_I(inode)->ip_alloc_sem);
485485

486+
ocfs2_resv_discard(&osb->osb_la_resmap,
487+
&OCFS2_I(inode)->ip_la_data_resv);
488+
486489
/*
487490
* The inode lock forced other nodes to sync and drop their
488491
* pages, which (correctly) happens even if we have a truncate

‎fs/ocfs2/inode.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,10 @@ void ocfs2_clear_inode(struct inode *inode)
10961096
ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres);
10971097
ocfs2_mark_lockres_freeing(&oi->ip_open_lockres);
10981098

1099+
ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap,
1100+
&oi->ip_la_data_resv);
1101+
ocfs2_resv_init_once(&oi->ip_la_data_resv);
1102+
10991103
/* We very well may get a clear_inode before all an inodes
11001104
* metadata has hit disk. Of course, we can't drop any cluster
11011105
* locks until the journal has finished with it. The only

‎fs/ocfs2/inode.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ struct ocfs2_inode_info
7070
/* Only valid if the inode is the dir. */
7171
u32 ip_last_used_slot;
7272
u64 ip_last_used_group;
73+
74+
struct ocfs2_alloc_reservation ip_la_data_resv;
7375
};
7476

7577
/*

‎fs/ocfs2/super.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,8 @@ static void ocfs2_inode_init_once(void *data)
17071707
oi->ip_blkno = 0ULL;
17081708
oi->ip_clusters = 0;
17091709

1710+
ocfs2_resv_init_once(&oi->ip_la_data_resv);
1711+
17101712
ocfs2_lock_res_init_once(&oi->ip_rw_lockres);
17111713
ocfs2_lock_res_init_once(&oi->ip_inode_lockres);
17121714
ocfs2_lock_res_init_once(&oi->ip_open_lockres);

0 commit comments

Comments
 (0)