Skip to content

Commit ded74fd

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: don't use a xfs_log_iovec for ri_buf in log recovery
ri_buf just holds a pointer/len pair and is not a log iovec used for writing to the log. Switch to use a kvec instead. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 8bf931f commit ded74fd

17 files changed

Lines changed: 157 additions & 155 deletions

fs/xfs/libxfs/xfs_log_recover.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct xlog_recover_item {
104104
struct list_head ri_list;
105105
int ri_cnt; /* count of regions found */
106106
int ri_total; /* total regions */
107-
struct xfs_log_iovec *ri_buf; /* ptr to regions buffer */
107+
struct kvec *ri_buf; /* ptr to regions buffer */
108108
const struct xlog_recover_item_ops *ri_ops;
109109
};
110110

@@ -117,7 +117,7 @@ struct xlog_recover {
117117
struct list_head r_itemq; /* q for items */
118118
};
119119

120-
#define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].i_addr)
120+
#define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].iov_base)
121121

122122
#define XLOG_RECOVER_CRCPASS 0
123123
#define XLOG_RECOVER_PASS1 1

fs/xfs/xfs_attr_item.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -951,50 +951,50 @@ static inline void *
951951
xfs_attri_validate_name_iovec(
952952
struct xfs_mount *mp,
953953
struct xfs_attri_log_format *attri_formatp,
954-
const struct xfs_log_iovec *iovec,
954+
const struct kvec *iovec,
955955
unsigned int name_len)
956956
{
957-
if (iovec->i_len != xlog_calc_iovec_len(name_len)) {
957+
if (iovec->iov_len != xlog_calc_iovec_len(name_len)) {
958958
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
959959
attri_formatp, sizeof(*attri_formatp));
960960
return NULL;
961961
}
962962

963-
if (!xfs_attr_namecheck(attri_formatp->alfi_attr_filter, iovec->i_addr,
963+
if (!xfs_attr_namecheck(attri_formatp->alfi_attr_filter, iovec->iov_base,
964964
name_len)) {
965965
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
966966
attri_formatp, sizeof(*attri_formatp));
967967
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
968-
iovec->i_addr, iovec->i_len);
968+
iovec->iov_base, iovec->iov_len);
969969
return NULL;
970970
}
971971

972-
return iovec->i_addr;
972+
return iovec->iov_base;
973973
}
974974

975975
static inline void *
976976
xfs_attri_validate_value_iovec(
977977
struct xfs_mount *mp,
978978
struct xfs_attri_log_format *attri_formatp,
979-
const struct xfs_log_iovec *iovec,
979+
const struct kvec *iovec,
980980
unsigned int value_len)
981981
{
982-
if (iovec->i_len != xlog_calc_iovec_len(value_len)) {
982+
if (iovec->iov_len != xlog_calc_iovec_len(value_len)) {
983983
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
984984
attri_formatp, sizeof(*attri_formatp));
985985
return NULL;
986986
}
987987

988988
if ((attri_formatp->alfi_attr_filter & XFS_ATTR_PARENT) &&
989-
!xfs_parent_valuecheck(mp, iovec->i_addr, value_len)) {
989+
!xfs_parent_valuecheck(mp, iovec->iov_base, value_len)) {
990990
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
991991
attri_formatp, sizeof(*attri_formatp));
992992
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
993-
iovec->i_addr, iovec->i_len);
993+
iovec->iov_base, iovec->iov_len);
994994
return NULL;
995995
}
996996

997-
return iovec->i_addr;
997+
return iovec->iov_base;
998998
}
999999

10001000
STATIC int
@@ -1021,13 +1021,13 @@ xlog_recover_attri_commit_pass2(
10211021

10221022
/* Validate xfs_attri_log_format before the large memory allocation */
10231023
len = sizeof(struct xfs_attri_log_format);
1024-
if (item->ri_buf[i].i_len != len) {
1024+
if (item->ri_buf[i].iov_len != len) {
10251025
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1026-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
1026+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
10271027
return -EFSCORRUPTED;
10281028
}
10291029

1030-
attri_formatp = item->ri_buf[i].i_addr;
1030+
attri_formatp = item->ri_buf[i].iov_base;
10311031
if (!xfs_attri_validate(mp, attri_formatp)) {
10321032
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
10331033
attri_formatp, len);
@@ -1216,10 +1216,10 @@ xlog_recover_attrd_commit_pass2(
12161216
{
12171217
struct xfs_attrd_log_format *attrd_formatp;
12181218

1219-
attrd_formatp = item->ri_buf[0].i_addr;
1220-
if (item->ri_buf[0].i_len != sizeof(struct xfs_attrd_log_format)) {
1219+
attrd_formatp = item->ri_buf[0].iov_base;
1220+
if (item->ri_buf[0].iov_len != sizeof(struct xfs_attrd_log_format)) {
12211221
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
1222-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
1222+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
12231223
return -EFSCORRUPTED;
12241224
}
12251225

fs/xfs/xfs_bmap_item.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -654,24 +654,24 @@ xlog_recover_bui_commit_pass2(
654654
struct xfs_bui_log_format *bui_formatp;
655655
size_t len;
656656

657-
bui_formatp = item->ri_buf[0].i_addr;
657+
bui_formatp = item->ri_buf[0].iov_base;
658658

659-
if (item->ri_buf[0].i_len < xfs_bui_log_format_sizeof(0)) {
659+
if (item->ri_buf[0].iov_len < xfs_bui_log_format_sizeof(0)) {
660660
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
661-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
661+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
662662
return -EFSCORRUPTED;
663663
}
664664

665665
if (bui_formatp->bui_nextents != XFS_BUI_MAX_FAST_EXTENTS) {
666666
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
667-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
667+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
668668
return -EFSCORRUPTED;
669669
}
670670

671671
len = xfs_bui_log_format_sizeof(bui_formatp->bui_nextents);
672-
if (item->ri_buf[0].i_len != len) {
672+
if (item->ri_buf[0].iov_len != len) {
673673
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
674-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
674+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
675675
return -EFSCORRUPTED;
676676
}
677677

@@ -705,10 +705,10 @@ xlog_recover_bud_commit_pass2(
705705
{
706706
struct xfs_bud_log_format *bud_formatp;
707707

708-
bud_formatp = item->ri_buf[0].i_addr;
709-
if (item->ri_buf[0].i_len != sizeof(struct xfs_bud_log_format)) {
708+
bud_formatp = item->ri_buf[0].iov_base;
709+
if (item->ri_buf[0].iov_len != sizeof(struct xfs_bud_log_format)) {
710710
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
711-
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
711+
item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
712712
return -EFSCORRUPTED;
713713
}
714714

fs/xfs/xfs_buf_item.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ xfs_buf_item_relse(
9090
/* Is this log iovec plausibly large enough to contain the buffer log format? */
9191
bool
9292
xfs_buf_log_check_iovec(
93-
struct xfs_log_iovec *iovec)
93+
struct kvec *iovec)
9494
{
95-
struct xfs_buf_log_format *blfp = iovec->i_addr;
95+
struct xfs_buf_log_format *blfp = iovec->iov_base;
9696
char *bmp_end;
9797
char *item_end;
9898

99-
if (offsetof(struct xfs_buf_log_format, blf_data_map) > iovec->i_len)
99+
if (offsetof(struct xfs_buf_log_format, blf_data_map) > iovec->iov_len)
100100
return false;
101101

102-
item_end = (char *)iovec->i_addr + iovec->i_len;
102+
item_end = (char *)iovec->iov_base + iovec->iov_len;
103103
bmp_end = (char *)&blfp->blf_data_map[blfp->blf_map_size];
104104
return bmp_end <= item_end;
105105
}

fs/xfs/xfs_buf_item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
6161
}
6262
#endif /* CONFIG_XFS_QUOTA */
6363
void xfs_buf_iodone(struct xfs_buf *);
64-
bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);
64+
bool xfs_buf_log_check_iovec(struct kvec *iovec);
6565

6666
unsigned int xfs_buf_inval_log_space(unsigned int map_count,
6767
unsigned int blocksize);

fs/xfs/xfs_buf_item_recover.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ STATIC enum xlog_recover_reorder
159159
xlog_recover_buf_reorder(
160160
struct xlog_recover_item *item)
161161
{
162-
struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
162+
struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
163163

164164
if (buf_f->blf_flags & XFS_BLF_CANCEL)
165165
return XLOG_REORDER_CANCEL_LIST;
@@ -173,7 +173,7 @@ xlog_recover_buf_ra_pass2(
173173
struct xlog *log,
174174
struct xlog_recover_item *item)
175175
{
176-
struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
176+
struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
177177

178178
xlog_buf_readahead(log, buf_f->blf_blkno, buf_f->blf_len, NULL);
179179
}
@@ -187,11 +187,11 @@ xlog_recover_buf_commit_pass1(
187187
struct xlog *log,
188188
struct xlog_recover_item *item)
189189
{
190-
struct xfs_buf_log_format *bf = item->ri_buf[0].i_addr;
190+
struct xfs_buf_log_format *bf = item->ri_buf[0].iov_base;
191191

192192
if (!xfs_buf_log_check_iovec(&item->ri_buf[0])) {
193-
xfs_err(log->l_mp, "bad buffer log item size (%d)",
194-
item->ri_buf[0].i_len);
193+
xfs_err(log->l_mp, "bad buffer log item size (%zd)",
194+
item->ri_buf[0].iov_len);
195195
return -EFSCORRUPTED;
196196
}
197197

@@ -487,8 +487,8 @@ xlog_recover_do_reg_buffer(
487487
nbits = xfs_contig_bits(buf_f->blf_data_map,
488488
buf_f->blf_map_size, bit);
489489
ASSERT(nbits > 0);
490-
ASSERT(item->ri_buf[i].i_addr != NULL);
491-
ASSERT(item->ri_buf[i].i_len % XFS_BLF_CHUNK == 0);
490+
ASSERT(item->ri_buf[i].iov_base != NULL);
491+
ASSERT(item->ri_buf[i].iov_len % XFS_BLF_CHUNK == 0);
492492
ASSERT(BBTOB(bp->b_length) >=
493493
((uint)bit << XFS_BLF_SHIFT) + (nbits << XFS_BLF_SHIFT));
494494

@@ -500,8 +500,8 @@ xlog_recover_do_reg_buffer(
500500
* the log. Hence we need to trim nbits back to the length of
501501
* the current region being copied out of the log.
502502
*/
503-
if (item->ri_buf[i].i_len < (nbits << XFS_BLF_SHIFT))
504-
nbits = item->ri_buf[i].i_len >> XFS_BLF_SHIFT;
503+
if (item->ri_buf[i].iov_len < (nbits << XFS_BLF_SHIFT))
504+
nbits = item->ri_buf[i].iov_len >> XFS_BLF_SHIFT;
505505

506506
/*
507507
* Do a sanity check if this is a dquot buffer. Just checking
@@ -511,18 +511,18 @@ xlog_recover_do_reg_buffer(
511511
fa = NULL;
512512
if (buf_f->blf_flags &
513513
(XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) {
514-
if (item->ri_buf[i].i_addr == NULL) {
514+
if (item->ri_buf[i].iov_base == NULL) {
515515
xfs_alert(mp,
516516
"XFS: NULL dquot in %s.", __func__);
517517
goto next;
518518
}
519-
if (item->ri_buf[i].i_len < size_disk_dquot) {
519+
if (item->ri_buf[i].iov_len < size_disk_dquot) {
520520
xfs_alert(mp,
521-
"XFS: dquot too small (%d) in %s.",
522-
item->ri_buf[i].i_len, __func__);
521+
"XFS: dquot too small (%zd) in %s.",
522+
item->ri_buf[i].iov_len, __func__);
523523
goto next;
524524
}
525-
fa = xfs_dquot_verify(mp, item->ri_buf[i].i_addr, -1);
525+
fa = xfs_dquot_verify(mp, item->ri_buf[i].iov_base, -1);
526526
if (fa) {
527527
xfs_alert(mp,
528528
"dquot corrupt at %pS trying to replay into block 0x%llx",
@@ -533,7 +533,7 @@ xlog_recover_do_reg_buffer(
533533

534534
memcpy(xfs_buf_offset(bp,
535535
(uint)bit << XFS_BLF_SHIFT), /* dest */
536-
item->ri_buf[i].i_addr, /* source */
536+
item->ri_buf[i].iov_base, /* source */
537537
nbits<<XFS_BLF_SHIFT); /* length */
538538
next:
539539
i++;
@@ -669,16 +669,16 @@ xlog_recover_do_inode_buffer(
669669
if (next_unlinked_offset < reg_buf_offset)
670670
continue;
671671

672-
ASSERT(item->ri_buf[item_index].i_addr != NULL);
673-
ASSERT((item->ri_buf[item_index].i_len % XFS_BLF_CHUNK) == 0);
672+
ASSERT(item->ri_buf[item_index].iov_base != NULL);
673+
ASSERT((item->ri_buf[item_index].iov_len % XFS_BLF_CHUNK) == 0);
674674
ASSERT((reg_buf_offset + reg_buf_bytes) <= BBTOB(bp->b_length));
675675

676676
/*
677677
* The current logged region contains a copy of the
678678
* current di_next_unlinked field. Extract its value
679679
* and copy it to the buffer copy.
680680
*/
681-
logged_nextp = item->ri_buf[item_index].i_addr +
681+
logged_nextp = item->ri_buf[item_index].iov_base +
682682
next_unlinked_offset - reg_buf_offset;
683683
if (XFS_IS_CORRUPT(mp, *logged_nextp == 0)) {
684684
xfs_alert(mp,
@@ -1002,7 +1002,7 @@ xlog_recover_buf_commit_pass2(
10021002
struct xlog_recover_item *item,
10031003
xfs_lsn_t current_lsn)
10041004
{
1005-
struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
1005+
struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
10061006
struct xfs_mount *mp = log->l_mp;
10071007
struct xfs_buf *bp;
10081008
int error;

fs/xfs/xfs_dquot_item_recover.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ xlog_recover_dquot_ra_pass2(
3434
if (mp->m_qflags == 0)
3535
return;
3636

37-
recddq = item->ri_buf[1].i_addr;
37+
recddq = item->ri_buf[1].iov_base;
3838
if (recddq == NULL)
3939
return;
40-
if (item->ri_buf[1].i_len < sizeof(struct xfs_disk_dquot))
40+
if (item->ri_buf[1].iov_len < sizeof(struct xfs_disk_dquot))
4141
return;
4242

4343
type = recddq->d_type & XFS_DQTYPE_REC_MASK;
4444
ASSERT(type);
4545
if (log->l_quotaoffs_flag & type)
4646
return;
4747

48-
dq_f = item->ri_buf[0].i_addr;
48+
dq_f = item->ri_buf[0].iov_base;
4949
ASSERT(dq_f);
5050
ASSERT(dq_f->qlf_len == 1);
5151

@@ -79,14 +79,14 @@ xlog_recover_dquot_commit_pass2(
7979
if (mp->m_qflags == 0)
8080
return 0;
8181

82-
recddq = item->ri_buf[1].i_addr;
82+
recddq = item->ri_buf[1].iov_base;
8383
if (recddq == NULL) {
8484
xfs_alert(log->l_mp, "NULL dquot in %s.", __func__);
8585
return -EFSCORRUPTED;
8686
}
87-
if (item->ri_buf[1].i_len < sizeof(struct xfs_disk_dquot)) {
88-
xfs_alert(log->l_mp, "dquot too small (%d) in %s.",
89-
item->ri_buf[1].i_len, __func__);
87+
if (item->ri_buf[1].iov_len < sizeof(struct xfs_disk_dquot)) {
88+
xfs_alert(log->l_mp, "dquot too small (%zd) in %s.",
89+
item->ri_buf[1].iov_len, __func__);
9090
return -EFSCORRUPTED;
9191
}
9292

@@ -108,7 +108,7 @@ xlog_recover_dquot_commit_pass2(
108108
* The other possibility, of course, is that the quota subsystem was
109109
* removed since the last mount - ENOSYS.
110110
*/
111-
dq_f = item->ri_buf[0].i_addr;
111+
dq_f = item->ri_buf[0].iov_base;
112112
ASSERT(dq_f);
113113
fa = xfs_dquot_verify(mp, recddq, dq_f->qlf_id);
114114
if (fa) {
@@ -147,7 +147,7 @@ xlog_recover_dquot_commit_pass2(
147147
}
148148
}
149149

150-
memcpy(ddq, recddq, item->ri_buf[1].i_len);
150+
memcpy(ddq, recddq, item->ri_buf[1].iov_len);
151151
if (xfs_has_crc(mp)) {
152152
xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
153153
XFS_DQUOT_CRC_OFF);
@@ -192,7 +192,7 @@ xlog_recover_quotaoff_commit_pass1(
192192
struct xlog *log,
193193
struct xlog_recover_item *item)
194194
{
195-
struct xfs_qoff_logformat *qoff_f = item->ri_buf[0].i_addr;
195+
struct xfs_qoff_logformat *qoff_f = item->ri_buf[0].iov_base;
196196
ASSERT(qoff_f);
197197

198198
/*

fs/xfs/xfs_exchmaps_item.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,12 @@ xlog_recover_xmi_commit_pass2(
558558
size_t len;
559559

560560
len = sizeof(struct xfs_xmi_log_format);
561-
if (item->ri_buf[0].i_len != len) {
561+
if (item->ri_buf[0].iov_len != len) {
562562
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
563563
return -EFSCORRUPTED;
564564
}
565565

566-
xmi_formatp = item->ri_buf[0].i_addr;
566+
xmi_formatp = item->ri_buf[0].iov_base;
567567
if (xmi_formatp->__pad != 0) {
568568
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
569569
return -EFSCORRUPTED;
@@ -598,8 +598,8 @@ xlog_recover_xmd_commit_pass2(
598598
{
599599
struct xfs_xmd_log_format *xmd_formatp;
600600

601-
xmd_formatp = item->ri_buf[0].i_addr;
602-
if (item->ri_buf[0].i_len != sizeof(struct xfs_xmd_log_format)) {
601+
xmd_formatp = item->ri_buf[0].iov_base;
602+
if (item->ri_buf[0].iov_len != sizeof(struct xfs_xmd_log_format)) {
603603
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
604604
return -EFSCORRUPTED;
605605
}

0 commit comments

Comments
 (0)