Skip to content

Commit dbcb5e7

Browse files
Martin Brandenburghubcapsc
authored andcommitted
orangefs: open code short single-use functions
Signed-off-by: Martin Brandenburg <[email protected]> Signed-off-by: Mike Marshall <[email protected]>
1 parent 81e3d02 commit dbcb5e7

File tree

1 file changed

+19
-76
lines changed

1 file changed

+19
-76
lines changed

fs/orangefs/file.c

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -41,70 +41,6 @@ static int flush_racache(struct inode *inode)
4141
return ret;
4242
}
4343

44-
/*
45-
* Copy to client-core's address space from the buffers specified
46-
* by the iovec upto total_size bytes.
47-
* NOTE: the iovector can either contain addresses which
48-
* can futher be kernel-space or user-space addresses.
49-
* or it can pointers to struct page's
50-
*/
51-
static int precopy_buffers(int buffer_index,
52-
struct iov_iter *iter,
53-
size_t total_size)
54-
{
55-
int ret = 0;
56-
/*
57-
* copy data from application/kernel by pulling it out
58-
* of the iovec.
59-
*/
60-
61-
62-
if (total_size) {
63-
ret = orangefs_bufmap_copy_from_iovec(iter,
64-
buffer_index,
65-
total_size);
66-
if (ret < 0)
67-
gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n",
68-
__func__,
69-
(long)ret);
70-
}
71-
72-
if (ret < 0)
73-
gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n",
74-
__func__,
75-
(long)ret);
76-
return ret;
77-
}
78-
79-
/*
80-
* Copy from client-core's address space to the buffers specified
81-
* by the iovec upto total_size bytes.
82-
* NOTE: the iovector can either contain addresses which
83-
* can futher be kernel-space or user-space addresses.
84-
* or it can pointers to struct page's
85-
*/
86-
static int postcopy_buffers(int buffer_index,
87-
struct iov_iter *iter,
88-
size_t total_size)
89-
{
90-
int ret = 0;
91-
/*
92-
* copy data to application/kernel by pushing it out to
93-
* the iovec. NOTE; target buffers can be addresses or
94-
* struct page pointers.
95-
*/
96-
if (total_size) {
97-
ret = orangefs_bufmap_copy_to_iovec(iter,
98-
buffer_index,
99-
total_size);
100-
if (ret < 0)
101-
gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n",
102-
__func__,
103-
(long)ret);
104-
}
105-
return ret;
106-
}
107-
10844
/*
10945
* Post and wait for the I/O upcall to finish
11046
*/
@@ -157,14 +93,15 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod
15793
total_size);
15894
/*
15995
* Stage 1: copy the buffers into client-core's address space
160-
* precopy_buffers only pertains to writes.
16196
*/
162-
if (type == ORANGEFS_IO_WRITE) {
163-
ret = precopy_buffers(buffer_index,
164-
iter,
165-
total_size);
166-
if (ret < 0)
97+
if (type == ORANGEFS_IO_WRITE && total_size) {
98+
ret = orangefs_bufmap_copy_from_iovec(iter, buffer_index,
99+
total_size);
100+
if (ret < 0) {
101+
gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n",
102+
__func__, (long)ret);
167103
goto out;
104+
}
168105
}
169106

170107
gossip_debug(GOSSIP_FILE_DEBUG,
@@ -260,14 +197,20 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod
260197

261198
/*
262199
* Stage 3: Post copy buffers from client-core's address space
263-
* postcopy_buffers only pertains to reads.
264200
*/
265-
if (type == ORANGEFS_IO_READ) {
266-
ret = postcopy_buffers(buffer_index,
267-
iter,
268-
new_op->downcall.resp.io.amt_complete);
269-
if (ret < 0)
201+
if (type == ORANGEFS_IO_READ && new_op->downcall.resp.io.amt_complete) {
202+
/*
203+
* NOTE: the iovector can either contain addresses which
204+
* can futher be kernel-space or user-space addresses.
205+
* or it can pointers to struct page's
206+
*/
207+
ret = orangefs_bufmap_copy_to_iovec(iter, buffer_index,
208+
new_op->downcall.resp.io.amt_complete);
209+
if (ret < 0) {
210+
gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n",
211+
__func__, (long)ret);
270212
goto out;
213+
}
271214
}
272215
gossip_debug(GOSSIP_FILE_DEBUG,
273216
"%s(%pU): Amount %s, returned by the sys-io call:%d\n",

0 commit comments

Comments
 (0)