Skip to content

Commit f8d920a

Browse files
committed
erofs: reference struct erofs_device_info for erofs_map_dev
Record `m_sb` and `m_dif` to replace `m_fscache`, `m_daxdev`, `m_fp` and `m_dax_part_off` in order to simplify the codebase. Note that `m_bdev` is still left since it can be assigned from `sb->s_bdev` directly. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7b00af2 commit f8d920a

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

fs/erofs/data.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,13 @@ int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
179179
}
180180

181181
static void erofs_fill_from_devinfo(struct erofs_map_dev *map,
182-
struct erofs_device_info *dif)
182+
struct super_block *sb, struct erofs_device_info *dif)
183183
{
184+
map->m_sb = sb;
185+
map->m_dif = dif;
184186
map->m_bdev = NULL;
185-
map->m_fp = NULL;
186-
if (dif->file) {
187-
if (S_ISBLK(file_inode(dif->file)->i_mode))
188-
map->m_bdev = file_bdev(dif->file);
189-
else
190-
map->m_fp = dif->file;
191-
}
192-
map->m_daxdev = dif->dax_dev;
193-
map->m_dax_part_off = dif->dax_part_off;
194-
map->m_fscache = dif->fscache;
187+
if (dif->file && S_ISBLK(file_inode(dif->file)->i_mode))
188+
map->m_bdev = file_bdev(dif->file);
195189
}
196190

197191
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
@@ -201,7 +195,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
201195
erofs_off_t startoff, length;
202196
int id;
203197

204-
erofs_fill_from_devinfo(map, &EROFS_SB(sb)->dif0);
198+
erofs_fill_from_devinfo(map, sb, &EROFS_SB(sb)->dif0);
205199
map->m_bdev = sb->s_bdev; /* use s_bdev for the primary device */
206200
if (map->m_deviceid) {
207201
down_read(&devs->rwsem);
@@ -215,7 +209,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
215209
up_read(&devs->rwsem);
216210
return 0;
217211
}
218-
erofs_fill_from_devinfo(map, dif);
212+
erofs_fill_from_devinfo(map, sb, dif);
219213
up_read(&devs->rwsem);
220214
} else if (devs->extra_devices && !devs->flatdev) {
221215
down_read(&devs->rwsem);
@@ -228,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
228222
if (map->m_pa >= startoff &&
229223
map->m_pa < startoff + length) {
230224
map->m_pa -= startoff;
231-
erofs_fill_from_devinfo(map, dif);
225+
erofs_fill_from_devinfo(map, sb, dif);
232226
break;
233227
}
234228
}
@@ -298,7 +292,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
298292

299293
iomap->offset = map.m_la;
300294
if (flags & IOMAP_DAX)
301-
iomap->dax_dev = mdev.m_daxdev;
295+
iomap->dax_dev = mdev.m_dif->dax_dev;
302296
else
303297
iomap->bdev = mdev.m_bdev;
304298
iomap->length = map.m_llen;
@@ -327,7 +321,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
327321
iomap->type = IOMAP_MAPPED;
328322
iomap->addr = mdev.m_pa;
329323
if (flags & IOMAP_DAX)
330-
iomap->addr += mdev.m_dax_part_off;
324+
iomap->addr += mdev.m_dif->dax_part_off;
331325
}
332326
return 0;
333327
}

fs/erofs/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
6767
GFP_KERNEL | __GFP_NOFAIL);
6868

6969
bio_init(&rq->bio, NULL, rq->bvecs, BIO_MAX_VECS, REQ_OP_READ);
70-
rq->iocb.ki_filp = mdev->m_fp;
70+
rq->iocb.ki_filp = mdev->m_dif->file;
7171
return rq;
7272
}
7373

fs/erofs/fscache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev)
198198

199199
io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
200200
bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
201-
io->io.private = mdev->m_fscache->cookie;
201+
io->io.private = mdev->m_dif->fscache->cookie;
202202
io->io.end_io = erofs_fscache_bio_endio;
203203
refcount_set(&io->io.ref, 1);
204204
return &io->bio;
@@ -316,7 +316,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
316316
if (!io)
317317
return -ENOMEM;
318318
iov_iter_xarray(&io->iter, ITER_DEST, &mapping->i_pages, pos, count);
319-
ret = erofs_fscache_read_io_async(mdev.m_fscache->cookie,
319+
ret = erofs_fscache_read_io_async(mdev.m_dif->fscache->cookie,
320320
mdev.m_pa + (pos - map.m_la), io);
321321
erofs_fscache_req_io_put(io);
322322

fs/erofs/internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,9 @@ enum {
353353
};
354354

355355
struct erofs_map_dev {
356-
struct erofs_fscache *m_fscache;
356+
struct super_block *m_sb;
357+
struct erofs_device_info *m_dif;
357358
struct block_device *m_bdev;
358-
struct dax_device *m_daxdev;
359-
struct file *m_fp;
360-
u64 m_dax_part_off;
361359

362360
erofs_off_t m_pa;
363361
unsigned int m_deviceid;

0 commit comments

Comments
 (0)