mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
btrfs: use pgoff_t for page index variables
Any conversion of offsets in the logical or the physical mapping space of the pages is done by a shift and the target type should be pgoff_t (type of struct page::index). Fix the locations where it's still unsigned long. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
afd1dacbd0
commit
ab5fcbb1ad
8 changed files with 22 additions and 24 deletions
|
@ -282,8 +282,8 @@ static noinline void end_compressed_writeback(const struct compressed_bio *cb)
|
|||
{
|
||||
struct inode *inode = &cb->bbio.inode->vfs_inode;
|
||||
struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
|
||||
unsigned long index = cb->start >> PAGE_SHIFT;
|
||||
unsigned long end_index = (cb->start + cb->len - 1) >> PAGE_SHIFT;
|
||||
pgoff_t index = cb->start >> PAGE_SHIFT;
|
||||
const pgoff_t end_index = (cb->start + cb->len - 1) >> PAGE_SHIFT;
|
||||
struct folio_batch fbatch;
|
||||
int i;
|
||||
int ret;
|
||||
|
@ -415,7 +415,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
|
|||
int *memstall, unsigned long *pflags)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
|
||||
unsigned long end_index;
|
||||
pgoff_t end_index;
|
||||
struct bio *orig_bio = &cb->orig_bbio->bio;
|
||||
u64 cur = cb->orig_bbio->file_offset + orig_bio->bi_iter.bi_size;
|
||||
u64 isize = i_size_read(inode);
|
||||
|
@ -446,8 +446,8 @@ static noinline int add_ra_bio_pages(struct inode *inode,
|
|||
end_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
|
||||
|
||||
while (cur < compressed_end) {
|
||||
u64 page_end;
|
||||
u64 pg_index = cur >> PAGE_SHIFT;
|
||||
pgoff_t page_end;
|
||||
pgoff_t pg_index = cur >> PAGE_SHIFT;
|
||||
u32 add_size;
|
||||
|
||||
if (pg_index > end_index)
|
||||
|
@ -1482,7 +1482,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
|
|||
struct heuristic_ws *ws)
|
||||
{
|
||||
struct page *page;
|
||||
u64 index, index_end;
|
||||
pgoff_t index, index_end;
|
||||
u32 i, curr_sample_pos;
|
||||
u8 *in_data;
|
||||
|
||||
|
|
|
@ -1662,7 +1662,7 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
|
|||
int ret;
|
||||
size_t pg_offset;
|
||||
loff_t i_size = i_size_read(&inode->vfs_inode);
|
||||
unsigned long end_index = i_size >> PAGE_SHIFT;
|
||||
const pgoff_t end_index = i_size >> PAGE_SHIFT;
|
||||
const unsigned int blocks_per_folio = btrfs_blocks_per_folio(fs_info, folio);
|
||||
|
||||
trace_extent_writepage(folio, &inode->vfs_inode, bio_ctrl->wbc);
|
||||
|
@ -3146,7 +3146,7 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,
|
|||
|
||||
struct btrfs_fs_info *fs_info = eb->fs_info;
|
||||
struct address_space *mapping = fs_info->btree_inode->i_mapping;
|
||||
const unsigned long index = eb->start >> PAGE_SHIFT;
|
||||
const pgoff_t index = eb->start >> PAGE_SHIFT;
|
||||
struct folio *existing_folio;
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -856,7 +856,7 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_
|
|||
loff_t pos, size_t write_bytes,
|
||||
bool nowait)
|
||||
{
|
||||
unsigned long index = pos >> PAGE_SHIFT;
|
||||
const pgoff_t index = pos >> PAGE_SHIFT;
|
||||
gfp_t mask = get_prepare_gfp_flags(inode, nowait);
|
||||
fgf_t fgp_flags = (nowait ? FGP_WRITEBEGIN | FGP_NOWAIT : FGP_WRITEBEGIN) |
|
||||
fgf_set_order(write_bytes);
|
||||
|
|
|
@ -366,7 +366,7 @@ fail:
|
|||
static void readahead_cache(struct inode *inode)
|
||||
{
|
||||
struct file_ra_state ra;
|
||||
unsigned long last_index;
|
||||
pgoff_t last_index;
|
||||
|
||||
file_ra_state_init(&ra, inode->i_mapping);
|
||||
last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
|
||||
|
|
|
@ -395,8 +395,8 @@ void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags)
|
|||
static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode,
|
||||
u64 offset, u64 bytes)
|
||||
{
|
||||
unsigned long index = offset >> PAGE_SHIFT;
|
||||
unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT;
|
||||
pgoff_t index = offset >> PAGE_SHIFT;
|
||||
const pgoff_t end_index = (offset + bytes - 1) >> PAGE_SHIFT;
|
||||
struct folio *folio;
|
||||
|
||||
while (index <= end_index) {
|
||||
|
@ -808,12 +808,11 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
|
|||
|
||||
static int extent_range_clear_dirty_for_io(struct btrfs_inode *inode, u64 start, u64 end)
|
||||
{
|
||||
unsigned long end_index = end >> PAGE_SHIFT;
|
||||
const pgoff_t end_index = end >> PAGE_SHIFT;
|
||||
struct folio *folio;
|
||||
int ret = 0;
|
||||
|
||||
for (unsigned long index = start >> PAGE_SHIFT;
|
||||
index <= end_index; index++) {
|
||||
for (pgoff_t index = start >> PAGE_SHIFT; index <= end_index; index++) {
|
||||
folio = filemap_get_folio(inode->vfs_inode.i_mapping, index);
|
||||
if (IS_ERR(folio)) {
|
||||
if (!ret)
|
||||
|
|
|
@ -4658,7 +4658,7 @@ static void btrfs_uring_read_finished(struct io_uring_cmd *cmd, unsigned int iss
|
|||
struct btrfs_uring_priv *priv = bc->priv;
|
||||
struct btrfs_inode *inode = BTRFS_I(file_inode(priv->iocb.ki_filp));
|
||||
struct extent_io_tree *io_tree = &inode->io_tree;
|
||||
unsigned long index;
|
||||
pgoff_t index;
|
||||
u64 cur;
|
||||
size_t page_offset;
|
||||
ssize_t ret;
|
||||
|
|
|
@ -2814,13 +2814,13 @@ static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster,
|
|||
|
||||
static int relocate_one_folio(struct reloc_control *rc,
|
||||
struct file_ra_state *ra,
|
||||
int *cluster_nr, unsigned long index)
|
||||
int *cluster_nr, pgoff_t index)
|
||||
{
|
||||
const struct file_extent_cluster *cluster = &rc->cluster;
|
||||
struct inode *inode = rc->data_inode;
|
||||
struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
|
||||
u64 offset = BTRFS_I(inode)->reloc_block_group_start;
|
||||
const unsigned long last_index = (cluster->end - offset) >> PAGE_SHIFT;
|
||||
const pgoff_t last_index = (cluster->end - offset) >> PAGE_SHIFT;
|
||||
gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
|
||||
struct folio *folio;
|
||||
u64 folio_start;
|
||||
|
@ -2974,8 +2974,8 @@ static int relocate_file_extent_cluster(struct reloc_control *rc)
|
|||
struct inode *inode = rc->data_inode;
|
||||
const struct file_extent_cluster *cluster = &rc->cluster;
|
||||
u64 offset = BTRFS_I(inode)->reloc_block_group_start;
|
||||
unsigned long index;
|
||||
unsigned long last_index;
|
||||
pgoff_t index;
|
||||
pgoff_t last_index;
|
||||
struct file_ra_state *ra;
|
||||
int cluster_nr = 0;
|
||||
int ret = 0;
|
||||
|
|
|
@ -23,8 +23,8 @@ static noinline int process_page_range(struct inode *inode, u64 start, u64 end,
|
|||
{
|
||||
int ret;
|
||||
struct folio_batch fbatch;
|
||||
unsigned long index = start >> PAGE_SHIFT;
|
||||
unsigned long end_index = end >> PAGE_SHIFT;
|
||||
pgoff_t index = start >> PAGE_SHIFT;
|
||||
pgoff_t end_index = end >> PAGE_SHIFT;
|
||||
int i;
|
||||
int count = 0;
|
||||
int loops = 0;
|
||||
|
@ -114,7 +114,6 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
|
|||
struct extent_io_tree *tmp;
|
||||
struct page *page;
|
||||
struct page *locked_page = NULL;
|
||||
unsigned long index = 0;
|
||||
/* In this test we need at least 2 file extents at its maximum size */
|
||||
u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
|
||||
u64 total_dirty = 2 * max_bytes;
|
||||
|
@ -157,7 +156,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
|
|||
* everything to make sure our pages don't get evicted and screw up our
|
||||
* test.
|
||||
*/
|
||||
for (index = 0; index < (total_dirty >> PAGE_SHIFT); index++) {
|
||||
for (pgoff_t index = 0; index < (total_dirty >> PAGE_SHIFT); index++) {
|
||||
page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
|
||||
if (!page) {
|
||||
test_err("failed to allocate test page");
|
||||
|
|
Loading…
Add table
Reference in a new issue