Skip to content

Commit

Permalink
fs/sysv: Use the offset_in_page() helper
Browse files Browse the repository at this point in the history
Use the offset_in_page() helper because it is more suitable than doing
explicit subtractions between pointers to directory entries and kernel
virtual addresses of mapped pages.

Cc: Ira Weiny <[email protected]>
Suggested-by: Al Viro <[email protected]>
Signed-off-by: Fabio M. De Francesco <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
xp4ns3 authored and Al Viro committed Jan 20, 2023
1 parent 4309093 commit 4bb1a13
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions fs/sysv/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
return -EINVAL;

got_it:
pos = page_offset(page) +
(char*)de - (char*)page_address(page);
pos = page_offset(page) + offset_in_page(de);
lock_page(page);
err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
if (err)
Expand All @@ -236,8 +235,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
{
struct inode *inode = page->mapping->host;
char *kaddr = (char*)page_address(page);
loff_t pos = page_offset(page) + (char *)de - kaddr;
loff_t pos = page_offset(page) + offset_in_page(de);
int err;

lock_page(page);
Expand Down Expand Up @@ -335,8 +333,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
struct inode *inode)
{
struct inode *dir = page->mapping->host;
loff_t pos = page_offset(page) +
(char *)de-(char*)page_address(page);
loff_t pos = page_offset(page) + offset_in_page(de);
int err;

lock_page(page);
Expand Down

0 comments on commit 4bb1a13

Please sign in to comment.