Skip to content

Commit b57c2cb

Browse files
Fabian FrederickAl Viro
authored andcommitted
pagemap.h: move dir_pages() over there
That function was declared in a lot of filesystems to calculate directory pages. Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e5e6e97 commit b57c2cb

8 files changed

Lines changed: 6 additions & 38 deletions

File tree

‎fs/exofs/dir.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ static inline void exofs_put_page(struct page *page)
4444
page_cache_release(page);
4545
}
4646

47-
/* Accesses dir's inode->i_size must be called under inode lock */
48-
static inline unsigned long dir_pages(struct inode *inode)
49-
{
50-
return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
51-
}
52-
5347
static unsigned exofs_last_byte(struct inode *inode, unsigned long page_nr)
5448
{
5549
loff_t last_byte = inode->i_size;

‎fs/ext2/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ static inline void ext2_put_page(struct page *page)
7070
page_cache_release(page);
7171
}
7272

73-
static inline unsigned long dir_pages(struct inode *inode)
74-
{
75-
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
76-
}
77-
7873
/*
7974
* Return the offset into page `page_nr' of the last valid
8075
* byte in that page, plus one.

‎fs/freevxfs/vxfs_lookup.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ const struct file_operations vxfs_dir_operations = {
6161
.iterate = vxfs_readdir,
6262
};
6363

64-
65-
static inline u_long
66-
dir_pages(struct inode *inode)
67-
{
68-
return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
69-
}
70-
7164
static inline u_long
7265
dir_blocks(struct inode *ip)
7366
{

‎fs/minix/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ minix_last_byte(struct inode *inode, unsigned long page_nr)
4545
return last_byte;
4646
}
4747

48-
static inline unsigned long dir_pages(struct inode *inode)
49-
{
50-
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
51-
}
52-
5348
static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
5449
{
5550
struct address_space *mapping = page->mapping;

‎fs/nilfs2/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ static inline void nilfs_put_page(struct page *page)
6161
page_cache_release(page);
6262
}
6363

64-
static inline unsigned long dir_pages(struct inode *inode)
65-
{
66-
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
67-
}
68-
6964
/*
7065
* Return the offset into page `page_nr' of the last valid
7166
* byte in that page, plus one.

‎fs/qnx6/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ static struct page *qnx6_get_page(struct inode *dir, unsigned long n)
3232
return page;
3333
}
3434

35-
static inline unsigned long dir_pages(struct inode *inode)
36-
{
37-
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
38-
}
39-
4035
static unsigned last_entry(struct inode *inode, unsigned long page_nr)
4136
{
4237
unsigned long last_byte = inode->i_size;

‎fs/sysv/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ static inline void dir_put_page(struct page *page)
3333
page_cache_release(page);
3434
}
3535

36-
static inline unsigned long dir_pages(struct inode *inode)
37-
{
38-
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
39-
}
40-
4136
static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
4237
{
4338
struct address_space *mapping = page->mapping;

‎include/linux/pagemap.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,4 +670,10 @@ static inline int add_to_page_cache(struct page *page,
670670
return error;
671671
}
672672

673+
static inline unsigned long dir_pages(struct inode *inode)
674+
{
675+
return (unsigned long)(inode->i_size + PAGE_CACHE_SIZE - 1) >>
676+
PAGE_CACHE_SHIFT;
677+
}
678+
673679
#endif /* _LINUX_PAGEMAP_H */

0 commit comments

Comments
 (0)