fs/sysv: Use the offset_in_page() helper

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 <ira.weiny@intel.com>
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Fabio M. De Francesco 2023-01-19 16:32:29 +01:00 коммит произвёл Al Viro
Родитель 4309093ecb
Коммит 4bb1a1375a
1 изменённых файлов: 3 добавлений и 6 удалений

Просмотреть файл

@ -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)
@ -236,8 +235,7 @@ out_unlock:
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);
@ -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);