Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

highmem: Rename put_and_unmap_page() to unmap_and_put_page()

With commit 849ad04cf562a ("new helper: put_and_unmap_page()"), Al Viro
introduced the put_and_unmap_page() to use in those many places where we
have a common pattern consisting of calls to kunmap_local() +
put_page().

Obviously, first we unmap and then we put pages. Instead, the original
name of this helper seems to imply that we first put and then unmap.

Therefore, rename the helper and change the only known upstreamed user
(i.e., fs/sysv) before this helper enters common use and might become
difficult to find all call sites and instead easy to break the builds.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Message-Id: <20230602103307.5637-1-fmdefrancesco@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Fabio M. De Francesco and committed by
Christian Brauner
d0e13540 79aa2849

+16 -16
+11 -11
fs/sysv/dir.c
··· 52 52 } 53 53 54 54 /* 55 - * Calls to dir_get_page()/put_and_unmap_page() must be nested according to the 55 + * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the 56 56 * rules documented in mm/highmem.rst. 57 57 * 58 58 * NOTE: sysv_find_entry() and sysv_dotdot() act as calls to dir_get_page() ··· 103 103 if (!dir_emit(ctx, name, strnlen(name,SYSV_NAMELEN), 104 104 fs16_to_cpu(SYSV_SB(sb), de->inode), 105 105 DT_UNKNOWN)) { 106 - put_and_unmap_page(page, kaddr); 106 + unmap_and_put_page(page, kaddr); 107 107 return 0; 108 108 } 109 109 } 110 - put_and_unmap_page(page, kaddr); 110 + unmap_and_put_page(page, kaddr); 111 111 } 112 112 return 0; 113 113 } ··· 131 131 * itself (as a parameter - res_dir). It does NOT read the inode of the 132 132 * entry - you'll have to do that yourself if you want to. 133 133 * 134 - * On Success put_and_unmap_page() should be called on *res_page. 134 + * On Success unmap_and_put_page() should be called on *res_page. 135 135 * 136 136 * sysv_find_entry() acts as a call to dir_get_page() and must be treated 137 137 * accordingly for nesting purposes. ··· 166 166 name, de->name)) 167 167 goto found; 168 168 } 169 - put_and_unmap_page(page, kaddr); 169 + unmap_and_put_page(page, kaddr); 170 170 } 171 171 172 172 if (++n >= npages) ··· 209 209 goto out_page; 210 210 de++; 211 211 } 212 - put_and_unmap_page(page, kaddr); 212 + unmap_and_put_page(page, kaddr); 213 213 } 214 214 BUG(); 215 215 return -EINVAL; ··· 228 228 mark_inode_dirty(dir); 229 229 err = sysv_handle_dirsync(dir); 230 230 out_page: 231 - put_and_unmap_page(page, kaddr); 231 + unmap_and_put_page(page, kaddr); 232 232 return err; 233 233 out_unlock: 234 234 unlock_page(page); ··· 321 321 if (de->name[1] != '.' || de->name[2]) 322 322 goto not_empty; 323 323 } 324 - put_and_unmap_page(page, kaddr); 324 + unmap_and_put_page(page, kaddr); 325 325 } 326 326 return 1; 327 327 328 328 not_empty: 329 - put_and_unmap_page(page, kaddr); 329 + unmap_and_put_page(page, kaddr); 330 330 return 0; 331 331 } 332 332 ··· 352 352 } 353 353 354 354 /* 355 - * Calls to dir_get_page()/put_and_unmap_page() must be nested according to the 355 + * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the 356 356 * rules documented in mm/highmem.rst. 357 357 * 358 358 * sysv_dotdot() acts as a call to dir_get_page() and must be treated ··· 376 376 377 377 if (de) { 378 378 res = fs16_to_cpu(SYSV_SB(dentry->d_sb), de->inode); 379 - put_and_unmap_page(page, de); 379 + unmap_and_put_page(page, de); 380 380 } 381 381 return res; 382 382 }
+4 -4
fs/sysv/namei.c
··· 164 164 inode->i_ctime = dir->i_ctime; 165 165 inode_dec_link_count(inode); 166 166 } 167 - put_and_unmap_page(page, de); 167 + unmap_and_put_page(page, de); 168 168 return err; 169 169 } 170 170 ··· 227 227 if (!new_de) 228 228 goto out_dir; 229 229 err = sysv_set_link(new_de, new_page, old_inode); 230 - put_and_unmap_page(new_page, new_de); 230 + unmap_and_put_page(new_page, new_de); 231 231 if (err) 232 232 goto out_dir; 233 233 new_inode->i_ctime = current_time(new_inode); ··· 256 256 257 257 out_dir: 258 258 if (dir_de) 259 - put_and_unmap_page(dir_page, dir_de); 259 + unmap_and_put_page(dir_page, dir_de); 260 260 out_old: 261 - put_and_unmap_page(old_page, old_de); 261 + unmap_and_put_page(old_page, old_de); 262 262 out: 263 263 return err; 264 264 }
+1 -1
include/linux/highmem.h
··· 507 507 zero_user_segments(&folio->page, start, start + length, 0, 0); 508 508 } 509 509 510 - static inline void put_and_unmap_page(struct page *page, void *addr) 510 + static inline void unmap_and_put_page(struct page *page, void *addr) 511 511 { 512 512 kunmap_local(addr); 513 513 put_page(page);