1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
From f48be0e8fd2cab95c170c8d504dd688dba90ca8c Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Thu, 7 Nov 2024 16:59:41 -0700
Subject: [PATCH 2/3] 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.
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>
(cherry picked from commit 2f96f95229b997a1b523f84fcb20b0d2082f0849)
Change-Id: Id0a8809fcbf3d415154b607223b9480ac45cd6cd
---
src/afs/LINUX/osi_vnodeops.c | 33 ++++++++-------------------------
1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index f60d79a19..c7f20aae1 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -3618,41 +3618,25 @@ static int
afs_linux_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len,
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);
- 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;
-}
# 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)
+ 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;
+ return -ENOMEM;
}
*pagep = page;
@@ -3665,7 +3649,6 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping,
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
--
2.47.0
|