Skip to content

Commit f8c4725

Browse files
committed
xfs: convert drop_writes to use the errortag mechanism
We now have enhanced error injection that can control the frequency with which errors happen, so convert drop_writes to use this. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Carlos Maiolino <[email protected]>
1 parent 9e24cfd commit f8c4725

File tree

5 files changed

+15
-68
lines changed

5 files changed

+15
-68
lines changed

fs/xfs/xfs_error.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static unsigned int xfs_errortag_random_default[] = {
5555
XFS_RANDOM_REFCOUNT_FINISH_ONE,
5656
XFS_RANDOM_BMAP_FINISH_ONE,
5757
XFS_RANDOM_AG_RESV_CRITICAL,
58+
XFS_RANDOM_DROP_WRITES,
5859
};
5960

6061
struct xfs_errortag_attr {
@@ -157,6 +158,7 @@ XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDA
157158
XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
158159
XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
159160
XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
161+
XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
160162

161163
static struct attribute *xfs_errortag_attrs[] = {
162164
XFS_ERRORTAG_ATTR_LIST(noerror),
@@ -187,6 +189,7 @@ static struct attribute *xfs_errortag_attrs[] = {
187189
XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
188190
XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
189191
XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
192+
XFS_ERRORTAG_ATTR_LIST(drop_writes),
190193
NULL,
191194
};
192195

fs/xfs/xfs_error.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
9696
#define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25
9797
#define XFS_ERRTAG_BMAP_FINISH_ONE 26
9898
#define XFS_ERRTAG_AG_RESV_CRITICAL 27
99-
#define XFS_ERRTAG_MAX 28
99+
/*
100+
* DEBUG mode instrumentation to test and/or trigger delayed allocation
101+
* block killing in the event of failed writes. When enabled, all
102+
* buffered writes are silenty dropped and handled as if they failed.
103+
* All delalloc blocks in the range of the write (including pre-existing
104+
* delalloc blocks!) are tossed as part of the write failure error
105+
* handling sequence.
106+
*/
107+
#define XFS_ERRTAG_DROP_WRITES 28
108+
#define XFS_ERRTAG_MAX 29
100109

101110
/*
102111
* Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -129,6 +138,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
129138
#define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
130139
#define XFS_RANDOM_BMAP_FINISH_ONE 1
131140
#define XFS_RANDOM_AG_RESV_CRITICAL 4
141+
#define XFS_RANDOM_DROP_WRITES 1
132142

133143
#ifdef DEBUG
134144
extern int xfs_errortag_init(struct xfs_mount *mp);

fs/xfs/xfs_iomap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ xfs_file_iomap_end_delalloc(
10971097
* Behave as if the write failed if drop writes is enabled. Set the NEW
10981098
* flag to force delalloc cleanup.
10991099
*/
1100-
if (xfs_mp_drop_writes(mp)) {
1100+
if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DROP_WRITES)) {
11011101
iomap->flags |= IOMAP_F_NEW;
11021102
written = 0;
11031103
}

fs/xfs/xfs_mount.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ typedef struct xfs_mount {
205205
*/
206206
unsigned int *m_errortag;
207207
struct xfs_kobj m_errortag_kobj;
208-
209-
/*
210-
* DEBUG mode instrumentation to test and/or trigger delayed allocation
211-
* block killing in the event of failed writes. When enabled, all
212-
* buffered writes are silenty dropped and handled as if they failed.
213-
* All delalloc blocks in the range of the write (including pre-existing
214-
* delalloc blocks!) are tossed as part of the write failure error
215-
* handling sequence.
216-
*/
217-
bool m_drop_writes;
218208
#endif
219209
} xfs_mount_t;
220210

@@ -333,20 +323,6 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
333323
return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
334324
}
335325

336-
#ifdef DEBUG
337-
static inline bool
338-
xfs_mp_drop_writes(struct xfs_mount *mp)
339-
{
340-
return mp->m_drop_writes;
341-
}
342-
#else
343-
static inline bool
344-
xfs_mp_drop_writes(struct xfs_mount *mp)
345-
{
346-
return 0;
347-
}
348-
#endif
349-
350326
/* per-AG block reservation data structures*/
351327
enum xfs_ag_resv_type {
352328
XFS_AG_RESV_NONE = 0,

fs/xfs/xfs_sysfs.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -90,49 +90,7 @@ to_mp(struct kobject *kobject)
9090
return container_of(kobj, struct xfs_mount, m_kobj);
9191
}
9292

93-
#ifdef DEBUG
94-
95-
STATIC ssize_t
96-
drop_writes_store(
97-
struct kobject *kobject,
98-
const char *buf,
99-
size_t count)
100-
{
101-
struct xfs_mount *mp = to_mp(kobject);
102-
int ret;
103-
int val;
104-
105-
ret = kstrtoint(buf, 0, &val);
106-
if (ret)
107-
return ret;
108-
109-
if (val == 1)
110-
mp->m_drop_writes = true;
111-
else if (val == 0)
112-
mp->m_drop_writes = false;
113-
else
114-
return -EINVAL;
115-
116-
return count;
117-
}
118-
119-
STATIC ssize_t
120-
drop_writes_show(
121-
struct kobject *kobject,
122-
char *buf)
123-
{
124-
struct xfs_mount *mp = to_mp(kobject);
125-
126-
return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_drop_writes ? 1 : 0);
127-
}
128-
XFS_SYSFS_ATTR_RW(drop_writes);
129-
130-
#endif /* DEBUG */
131-
13293
static struct attribute *xfs_mp_attrs[] = {
133-
#ifdef DEBUG
134-
ATTR_LIST(drop_writes),
135-
#endif
13694
NULL,
13795
};
13896

0 commit comments

Comments
 (0)