mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
Linux: Refactor afs_linux_write_begin() variants
The function afs_linux_write_begin() has 2 preprocessor selected implementations, one to handle the case where write_begin has a flag parameter and the other where it doesn't. Refactor the code to combine the 2 implementations using preprocessor conditionals for the function declaration and within the body of the function as needed. There are no functional changes. This refactoring is in preparation for additional changes that will be made to the afs_linux_write_begin() function. Change-Id: I5389ea562d834d847bc7413e6f58dc3be2e5aa31 Reviewed-on: https://gerrit.openafs.org/15897 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
This commit is contained in:
parent
ec14690531
commit
2f96f95229
@ -3609,13 +3609,23 @@ static int
|
||||
afs_linux_write_begin(struct file *file, struct address_space *mapping,
|
||||
loff_t pos, unsigned len,
|
||||
struct page **pagep, void **fsdata)
|
||||
# else
|
||||
static int
|
||||
afs_linux_write_begin(struct file *file, struct address_space *mapping,
|
||||
loff_t pos, unsigned len, unsigned flags,
|
||||
struct page **pagep, void **fsdata)
|
||||
# endif
|
||||
{
|
||||
struct page *page;
|
||||
pgoff_t index = pos >> PAGE_SHIFT;
|
||||
unsigned int from = pos & (PAGE_SIZE - 1);
|
||||
int code;
|
||||
|
||||
# if defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS)
|
||||
page = grab_cache_page_write_begin(mapping, index);
|
||||
# else
|
||||
page = grab_cache_page_write_begin(mapping, index, flags);
|
||||
# endif
|
||||
if (!page) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -3630,33 +3640,6 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping,
|
||||
|
||||
return code;
|
||||
}
|
||||
# else
|
||||
static int
|
||||
afs_linux_write_begin(struct file *file, struct address_space *mapping,
|
||||
loff_t pos, unsigned len, unsigned flags,
|
||||
struct page **pagep, void **fsdata)
|
||||
{
|
||||
struct page *page;
|
||||
pgoff_t index = pos >> PAGE_SHIFT;
|
||||
unsigned int from = pos & (PAGE_SIZE - 1);
|
||||
int code;
|
||||
|
||||
page = grab_cache_page_write_begin(mapping, index, flags);
|
||||
if (!page) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*pagep = page;
|
||||
|
||||
code = afs_linux_prepare_write(file, page, from, from + len);
|
||||
if (code) {
|
||||
unlock_page(page);
|
||||
put_page(page);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
# endif /* HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS */
|
||||
#endif /* STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN */
|
||||
|
||||
#ifndef STRUCT_DENTRY_OPERATIONS_HAS_D_AUTOMOUNT
|
||||
|
Loading…
Reference in New Issue
Block a user