File: | xlators/performance/read-ahead/src/read-ahead.c |
Location: | line 826, column 9 |
Description: | Value stored to 'ret' is never read |
1 | /* |
2 | Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> |
3 | This file is part of GlusterFS. |
4 | |
5 | This file is licensed to you under your choice of the GNU Lesser |
6 | General Public License, version 3 or any later version (LGPLv3 or |
7 | later), or the GNU General Public License, version 2 (GPLv2), in all |
8 | cases as published by the Free Software Foundation. |
9 | */ |
10 | |
11 | /* |
12 | TODO: |
13 | - handle O_DIRECT |
14 | - maintain offset, flush on lseek |
15 | - ensure efficient memory management in case of random seek |
16 | */ |
17 | |
18 | #ifndef _CONFIG_H |
19 | #define _CONFIG_H |
20 | #include "config.h" |
21 | #endif |
22 | |
23 | #include "glusterfs.h" |
24 | #include "logging.h" |
25 | #include "dict.h" |
26 | #include "xlator.h" |
27 | #include "read-ahead.h" |
28 | #include "statedump.h" |
29 | #include <assert.h> |
30 | #include <sys/time.h> |
31 | |
32 | static void |
33 | read_ahead (call_frame_t *frame, ra_file_t *file); |
34 | |
35 | |
36 | int |
37 | ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
38 | int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) |
39 | { |
40 | ra_conf_t *conf = NULL((void*)0); |
41 | ra_file_t *file = NULL((void*)0); |
42 | int ret = 0; |
43 | |
44 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 44, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
45 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 45, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
46 | |
47 | conf = this->private; |
48 | |
49 | if (op_ret == -1) { |
50 | goto unwind; |
51 | } |
52 | |
53 | file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t)__gf_calloc (1, sizeof (*file), gf_ra_mt_ra_file_t); |
54 | if (!file) { |
55 | op_ret = -1; |
56 | op_errno = ENOMEM12; |
57 | goto unwind; |
58 | } |
59 | |
60 | /* If O_DIRECT open, we disable caching on it */ |
61 | |
62 | if ((fd->flags & O_DIRECT040000) || ((fd->flags & O_ACCMODE0003) == O_WRONLY01)) |
63 | file->disabled = 1; |
64 | |
65 | file->offset = (unsigned long long) 0; |
66 | file->conf = conf; |
67 | file->pages.next = &file->pages; |
68 | file->pages.prev = &file->pages; |
69 | file->pages.offset = (unsigned long long) 0; |
70 | file->pages.file = file; |
71 | |
72 | ra_conf_lock (conf); |
73 | { |
74 | file->next = conf->files.next; |
75 | conf->files.next = file; |
76 | file->next->prev = file; |
77 | file->prev = &conf->files; |
78 | } |
79 | ra_conf_unlock (conf); |
80 | |
81 | file->fd = fd; |
82 | file->page_count = conf->page_count; |
83 | file->page_size = conf->page_size; |
84 | pthread_mutex_init (&file->file_lock, NULL((void*)0)); |
85 | |
86 | if (!file->disabled) { |
87 | file->page_count = 1; |
88 | } |
89 | |
90 | ret = fd_ctx_set (fd, this, (uint64_t)(long)file); |
91 | if (ret == -1) { |
92 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("cannot set read-ahead context information in fd (%p)" , fd); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 94, GF_LOG_WARNING, "cannot set read-ahead context information in fd (%p)" , fd); } while (0) |
93 | "cannot set read-ahead context information in fd (%p)",do { do { if (0) printf ("cannot set read-ahead context information in fd (%p)" , fd); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 94, GF_LOG_WARNING, "cannot set read-ahead context information in fd (%p)" , fd); } while (0) |
94 | fd)do { do { if (0) printf ("cannot set read-ahead context information in fd (%p)" , fd); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 94, GF_LOG_WARNING, "cannot set read-ahead context information in fd (%p)" , fd); } while (0); |
95 | ra_file_destroy (file); |
96 | op_ret = -1; |
97 | op_errno = ENOMEM12; |
98 | } |
99 | |
100 | unwind: |
101 | frame->local = NULL((void*)0); |
102 | |
103 | STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata)do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 103, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
104 | |
105 | return 0; |
106 | } |
107 | |
108 | |
109 | int |
110 | ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
111 | int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, |
112 | struct iatt *buf, struct iatt *preparent, |
113 | struct iatt *postparent, dict_t *xdata) |
114 | { |
115 | ra_conf_t *conf = NULL((void*)0); |
116 | ra_file_t *file = NULL((void*)0); |
117 | int ret = 0; |
118 | |
119 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 119, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
120 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 120, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
121 | |
122 | conf = this->private; |
123 | |
124 | if (op_ret == -1) { |
125 | goto unwind; |
126 | } |
127 | |
128 | file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t)__gf_calloc (1, sizeof (*file), gf_ra_mt_ra_file_t); |
129 | if (!file) { |
130 | op_ret = -1; |
131 | op_errno = ENOMEM12; |
132 | goto unwind; |
133 | } |
134 | |
135 | /* If O_DIRECT open, we disable caching on it */ |
136 | |
137 | if ((fd->flags & O_DIRECT040000) || ((fd->flags & O_ACCMODE0003) == O_WRONLY01)) |
138 | file->disabled = 1; |
139 | |
140 | file->offset = (unsigned long long) 0; |
141 | //file->size = fd->inode->buf.ia_size; |
142 | file->conf = conf; |
143 | file->pages.next = &file->pages; |
144 | file->pages.prev = &file->pages; |
145 | file->pages.offset = (unsigned long long) 0; |
146 | file->pages.file = file; |
147 | |
148 | ra_conf_lock (conf); |
149 | { |
150 | file->next = conf->files.next; |
151 | conf->files.next = file; |
152 | file->next->prev = file; |
153 | file->prev = &conf->files; |
154 | } |
155 | ra_conf_unlock (conf); |
156 | |
157 | file->fd = fd; |
158 | file->page_count = conf->page_count; |
159 | file->page_size = conf->page_size; |
160 | pthread_mutex_init (&file->file_lock, NULL((void*)0)); |
161 | |
162 | ret = fd_ctx_set (fd, this, (uint64_t)(long)file); |
163 | if (ret == -1) { |
164 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("cannot set read ahead context information in fd (%p)" , fd); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 166, GF_LOG_WARNING, "cannot set read ahead context information in fd (%p)" , fd); } while (0) |
165 | "cannot set read ahead context information in fd (%p)",do { do { if (0) printf ("cannot set read ahead context information in fd (%p)" , fd); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 166, GF_LOG_WARNING, "cannot set read ahead context information in fd (%p)" , fd); } while (0) |
166 | fd)do { do { if (0) printf ("cannot set read ahead context information in fd (%p)" , fd); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 166, GF_LOG_WARNING, "cannot set read ahead context information in fd (%p)" , fd); } while (0); |
167 | ra_file_destroy (file); |
168 | op_ret = -1; |
169 | op_errno = ENOMEM12; |
170 | } |
171 | |
172 | unwind: |
173 | STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 174, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0) |
174 | preparent, postparent, xdata)do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 174, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0); |
175 | |
176 | return 0; |
177 | } |
178 | |
179 | |
180 | int |
181 | ra_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, |
182 | fd_t *fd, dict_t *xdata) |
183 | { |
184 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 184, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
185 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "read-ahead.c", __FUNCTION__, 185, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
186 | |
187 | STACK_WIND (frame, ra_open_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 190, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = ra_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->open"; _new ->unwind_to = "ra_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
188 | FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 190, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = ra_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->open"; _new ->unwind_to = "ra_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
189 | FIRST_CHILD (this)->fops->open,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 190, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = ra_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->open"; _new ->unwind_to = "ra_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
190 | loc, flags, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 190, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = ra_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->open"; _new ->unwind_to = "ra_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
191 | |
192 | return 0; |
193 | } |
194 | |
195 | |
196 | int |
197 | ra_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, |
198 | mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) |
199 | { |
200 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 200, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
201 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "read-ahead.c", __FUNCTION__, 201, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
202 | |
203 | STACK_WIND (frame, ra_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = ra_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "ra_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
204 | FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = ra_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "ra_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
205 | FIRST_CHILD(this)->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = ra_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "ra_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
206 | loc, flags, mode, umask, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = ra_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "ra_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
207 | |
208 | return 0; |
209 | } |
210 | |
211 | /* free cache pages between offset and offset+size, |
212 | does not touch pages with frames waiting on it |
213 | */ |
214 | |
215 | static void |
216 | flush_region (call_frame_t *frame, ra_file_t *file, off_t offset, off_t size, |
217 | int for_write) |
218 | { |
219 | ra_page_t *trav = NULL((void*)0); |
220 | ra_page_t *next = NULL((void*)0); |
221 | |
222 | ra_file_lock (file); |
223 | { |
224 | trav = file->pages.next; |
225 | while (trav != &file->pages |
226 | && trav->offset < (offset + size)) { |
227 | |
228 | next = trav->next; |
229 | if (trav->offset >= offset) { |
230 | if (!trav->waitq) { |
231 | ra_page_purge (trav); |
232 | } |
233 | else { |
234 | trav->stale = 1; |
235 | |
236 | if (for_write) { |
237 | trav->poisoned = 1; |
238 | } |
239 | } |
240 | } |
241 | trav = next; |
242 | } |
243 | } |
244 | ra_file_unlock (file); |
245 | } |
246 | |
247 | |
248 | int |
249 | ra_release (xlator_t *this, fd_t *fd) |
250 | { |
251 | uint64_t tmp_file = 0; |
252 | int ret = 0; |
253 | |
254 | GF_VALIDATE_OR_GOTO ("read-ahead", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 254, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); |
255 | GF_VALIDATE_OR_GOTO (this->name, fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (this->name, "read-ahead.c", __FUNCTION__, 255, GF_LOG_ERROR , "invalid argument: " "fd"); } while (0); goto out; } } while (0); |
256 | |
257 | ret = fd_ctx_del (fd, this, &tmp_file); |
258 | |
259 | if (!ret) { |
260 | ra_file_destroy ((ra_file_t *)(long)tmp_file); |
261 | } |
262 | |
263 | out: |
264 | return 0; |
265 | } |
266 | |
267 | |
268 | void |
269 | read_ahead (call_frame_t *frame, ra_file_t *file) |
270 | { |
271 | off_t ra_offset = 0; |
272 | size_t ra_size = 0; |
273 | off_t trav_offset = 0; |
274 | ra_page_t *trav = NULL((void*)0); |
275 | off_t cap = 0; |
276 | char fault = 0; |
277 | |
278 | GF_VALIDATE_OR_GOTO ("read-ahead", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 278, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); |
279 | GF_VALIDATE_OR_GOTO (frame->this->name, file, out)do { if (!file) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "file"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 279, GF_LOG_ERROR, "invalid argument: " "file"); } while (0); goto out; } } while (0); |
280 | |
281 | if (!file->page_count) { |
282 | goto out; |
283 | } |
284 | |
285 | ra_size = file->page_size * file->page_count; |
286 | ra_offset = floor (file->offset, file->page_size)(((file->offset)/((file->page_size)?(file->page_size ):1))*(file->page_size)); |
287 | cap = file->size ? file->size : file->offset + ra_size; |
288 | |
289 | while (ra_offset < min (file->offset + ra_size, cap)((file->offset + ra_size)<(cap)?(file->offset + ra_size ):(cap))) { |
290 | |
291 | ra_file_lock (file); |
292 | { |
293 | trav = ra_page_get (file, ra_offset); |
294 | } |
295 | ra_file_unlock (file); |
296 | |
297 | if (!trav) |
298 | break; |
299 | |
300 | ra_offset += file->page_size; |
301 | } |
302 | |
303 | if (trav) { |
304 | /* comfortable enough */ |
305 | goto out; |
306 | } |
307 | |
308 | trav_offset = ra_offset; |
309 | |
310 | cap = file->size ? file->size : ra_offset + ra_size; |
311 | |
312 | while (trav_offset < min(ra_offset + ra_size, cap)((ra_offset + ra_size)<(cap)?(ra_offset + ra_size):(cap))) { |
313 | fault = 0; |
314 | ra_file_lock (file); |
315 | { |
316 | trav = ra_page_get (file, trav_offset); |
317 | if (!trav) { |
318 | fault = 1; |
319 | trav = ra_page_create (file, trav_offset); |
320 | if (trav) |
321 | trav->dirty = 1; |
322 | } |
323 | } |
324 | ra_file_unlock (file); |
325 | |
326 | if (!trav) { |
327 | /* OUT OF MEMORY */ |
328 | break; |
329 | } |
330 | |
331 | if (fault) { |
332 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("RA at offset=%""ll" "d", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 333, GF_LOG_TRACE, "RA at offset=%""ll" "d", trav_offset ); } while (0) |
333 | "RA at offset=%"PRId64, trav_offset)do { do { if (0) printf ("RA at offset=%""ll" "d", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 333, GF_LOG_TRACE, "RA at offset=%""ll" "d", trav_offset ); } while (0); |
334 | ra_page_fault (file, frame, trav_offset); |
335 | } |
336 | trav_offset += file->page_size; |
337 | } |
338 | |
339 | out: |
340 | return; |
341 | } |
342 | |
343 | |
344 | int |
345 | ra_need_atime_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
346 | int32_t op_ret, int32_t op_errno, struct iovec *vector, |
347 | int32_t count, struct iatt *stbuf, struct iobref *iobref, |
348 | dict_t *xdata) |
349 | { |
350 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 350, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
351 | STACK_DESTROY (frame->root); |
352 | return 0; |
353 | } |
354 | |
355 | |
356 | static void |
357 | dispatch_requests (call_frame_t *frame, ra_file_t *file) |
358 | { |
359 | ra_local_t *local = NULL((void*)0); |
360 | ra_conf_t *conf = NULL((void*)0); |
361 | off_t rounded_offset = 0; |
362 | off_t rounded_end = 0; |
363 | off_t trav_offset = 0; |
364 | ra_page_t *trav = NULL((void*)0); |
365 | call_frame_t *ra_frame = NULL((void*)0); |
366 | char need_atime_update = 1; |
367 | char fault = 0; |
368 | |
369 | GF_VALIDATE_OR_GOTO ("read-ahead", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 369, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); |
370 | GF_VALIDATE_OR_GOTO (frame->this->name, file, out)do { if (!file) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "file"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 370, GF_LOG_ERROR, "invalid argument: " "file"); } while (0); goto out; } } while (0); |
371 | |
372 | local = frame->local; |
373 | conf = file->conf; |
374 | |
375 | rounded_offset = floor (local->offset, file->page_size)(((local->offset)/((file->page_size)?(file->page_size ):1))*(file->page_size)); |
376 | rounded_end = roof (local->offset + local->size, file->page_size)((((local->offset + local->size)+(file->page_size)-1 )/((file->page_size)?(file->page_size):1))*(file->page_size )); |
377 | |
378 | trav_offset = rounded_offset; |
379 | |
380 | while (trav_offset < rounded_end) { |
381 | fault = 0; |
382 | |
383 | ra_file_lock (file); |
384 | { |
385 | trav = ra_page_get (file, trav_offset); |
386 | if (!trav) { |
387 | trav = ra_page_create (file, trav_offset); |
388 | if (!trav) { |
389 | local->op_ret = -1; |
390 | local->op_errno = ENOMEM12; |
391 | goto unlock; |
392 | } |
393 | fault = 1; |
394 | need_atime_update = 0; |
395 | } |
396 | trav->dirty = 0; |
397 | |
398 | if (trav->ready) { |
399 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("HIT at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 401, GF_LOG_TRACE, "HIT at offset=%""ll" "d""." , trav_offset); } while (0) |
400 | "HIT at offset=%"PRId64".",do { do { if (0) printf ("HIT at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 401, GF_LOG_TRACE, "HIT at offset=%""ll" "d""." , trav_offset); } while (0) |
401 | trav_offset)do { do { if (0) printf ("HIT at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 401, GF_LOG_TRACE, "HIT at offset=%""ll" "d""." , trav_offset); } while (0); |
402 | ra_frame_fill (trav, frame); |
403 | } else { |
404 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("IN-TRANSIT at offset=%""ll" "d"".", trav_offset); } while (0); _gf_log (frame->this->name, "read-ahead.c", __FUNCTION__, 406, GF_LOG_TRACE, "IN-TRANSIT at offset=%" "ll" "d"".", trav_offset); } while (0) |
405 | "IN-TRANSIT at offset=%"PRId64".",do { do { if (0) printf ("IN-TRANSIT at offset=%""ll" "d"".", trav_offset); } while (0); _gf_log (frame->this->name, "read-ahead.c", __FUNCTION__, 406, GF_LOG_TRACE, "IN-TRANSIT at offset=%" "ll" "d"".", trav_offset); } while (0) |
406 | trav_offset)do { do { if (0) printf ("IN-TRANSIT at offset=%""ll" "d"".", trav_offset); } while (0); _gf_log (frame->this->name, "read-ahead.c", __FUNCTION__, 406, GF_LOG_TRACE, "IN-TRANSIT at offset=%" "ll" "d"".", trav_offset); } while (0); |
407 | ra_wait_on_page (trav, frame); |
408 | need_atime_update = 0; |
409 | } |
410 | } |
411 | unlock: |
412 | ra_file_unlock (file); |
413 | |
414 | if (local->op_ret == -1) { |
415 | goto out; |
416 | } |
417 | |
418 | if (fault) { |
419 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("MISS at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 421, GF_LOG_TRACE, "MISS at offset=%""ll" "d" ".", trav_offset); } while (0) |
420 | "MISS at offset=%"PRId64".",do { do { if (0) printf ("MISS at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 421, GF_LOG_TRACE, "MISS at offset=%""ll" "d" ".", trav_offset); } while (0) |
421 | trav_offset)do { do { if (0) printf ("MISS at offset=%""ll" "d"".", trav_offset ); } while (0); _gf_log (frame->this->name, "read-ahead.c" , __FUNCTION__, 421, GF_LOG_TRACE, "MISS at offset=%""ll" "d" ".", trav_offset); } while (0); |
422 | ra_page_fault (file, frame, trav_offset); |
423 | } |
424 | |
425 | trav_offset += file->page_size; |
426 | } |
427 | |
428 | if (need_atime_update && conf->force_atime_update) { |
429 | /* TODO: use untimens() since readv() can confuse underlying |
430 | io-cache and others */ |
431 | ra_frame = copy_frame (frame); |
432 | if (ra_frame == NULL((void*)0)) { |
433 | goto out; |
434 | } |
435 | |
436 | STACK_WIND (ra_frame, ra_need_atime_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (ra_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 439, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_need_atime_cbk ; _new->root = ra_frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = ra_frame; _new->cookie = _new; _new-> wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_need_atime_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&ra_frame-> root->stack_lock); { _new->next = ra_frame->root-> frames.next; _new->prev = &ra_frame->root->frames ; if (ra_frame->root->frames.next) ra_frame->root-> frames.next->prev = _new; ra_frame->root->frames.next = _new; ra_frame->ref_count++; } pthread_spin_unlock (& ra_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (frame->this->children ->xlator); if (ra_frame->this->ctx->measure_latency ) gf_latency_begin (_new, (frame->this->children->xlator )->fops->readv); (frame->this->children->xlator )->fops->readv (_new, (frame->this->children-> xlator), file->fd, 1, 1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
437 | FIRST_CHILD (frame->this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (ra_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 439, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_need_atime_cbk ; _new->root = ra_frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = ra_frame; _new->cookie = _new; _new-> wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_need_atime_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&ra_frame-> root->stack_lock); { _new->next = ra_frame->root-> frames.next; _new->prev = &ra_frame->root->frames ; if (ra_frame->root->frames.next) ra_frame->root-> frames.next->prev = _new; ra_frame->root->frames.next = _new; ra_frame->ref_count++; } pthread_spin_unlock (& ra_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (frame->this->children ->xlator); if (ra_frame->this->ctx->measure_latency ) gf_latency_begin (_new, (frame->this->children->xlator )->fops->readv); (frame->this->children->xlator )->fops->readv (_new, (frame->this->children-> xlator), file->fd, 1, 1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
438 | FIRST_CHILD (frame->this)->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (ra_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 439, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_need_atime_cbk ; _new->root = ra_frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = ra_frame; _new->cookie = _new; _new-> wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_need_atime_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&ra_frame-> root->stack_lock); { _new->next = ra_frame->root-> frames.next; _new->prev = &ra_frame->root->frames ; if (ra_frame->root->frames.next) ra_frame->root-> frames.next->prev = _new; ra_frame->root->frames.next = _new; ra_frame->ref_count++; } pthread_spin_unlock (& ra_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (frame->this->children ->xlator); if (ra_frame->this->ctx->measure_latency ) gf_latency_begin (_new, (frame->this->children->xlator )->fops->readv); (frame->this->children->xlator )->fops->readv (_new, (frame->this->children-> xlator), file->fd, 1, 1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
439 | file->fd, 1, 1, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (ra_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 439, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_need_atime_cbk ; _new->root = ra_frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = ra_frame; _new->cookie = _new; _new-> wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_need_atime_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&ra_frame-> root->stack_lock); { _new->next = ra_frame->root-> frames.next; _new->prev = &ra_frame->root->frames ; if (ra_frame->root->frames.next) ra_frame->root-> frames.next->prev = _new; ra_frame->root->frames.next = _new; ra_frame->ref_count++; } pthread_spin_unlock (& ra_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (frame->this->children ->xlator); if (ra_frame->this->ctx->measure_latency ) gf_latency_begin (_new, (frame->this->children->xlator )->fops->readv); (frame->this->children->xlator )->fops->readv (_new, (frame->this->children-> xlator), file->fd, 1, 1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
440 | } |
441 | |
442 | out: |
443 | return ; |
444 | } |
445 | |
446 | |
447 | int |
448 | ra_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
449 | int32_t op_ret, int32_t op_errno, struct iovec *vector, |
450 | int32_t count, struct iatt *stbuf, struct iobref *iobref, |
451 | dict_t *xdata) |
452 | { |
453 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 453, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
454 | |
455 | STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, vector, count,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 456, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
456 | stbuf, iobref, xdata)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 456, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
457 | |
458 | return 0; |
459 | } |
460 | |
461 | |
462 | int |
463 | ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, |
464 | off_t offset, uint32_t flags, dict_t *xdata) |
465 | { |
466 | ra_file_t *file = NULL((void*)0); |
467 | ra_local_t *local = NULL((void*)0); |
468 | ra_conf_t *conf = NULL((void*)0); |
469 | int op_errno = EINVAL22; |
470 | char expected_offset = 1; |
471 | uint64_t tmp_file = 0; |
472 | |
473 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 473, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
474 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 474, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
475 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 475, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
476 | |
477 | conf = this->private; |
478 | |
479 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("NEW REQ at offset=%""ll" "d"" for size=%" "zu""", offset, size); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 481, GF_LOG_TRACE, "NEW REQ at offset=%""ll" "d" " for size=%""zu""", offset, size); } while (0) |
480 | "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"",do { do { if (0) printf ("NEW REQ at offset=%""ll" "d"" for size=%" "zu""", offset, size); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 481, GF_LOG_TRACE, "NEW REQ at offset=%""ll" "d" " for size=%""zu""", offset, size); } while (0) |
481 | offset, size)do { do { if (0) printf ("NEW REQ at offset=%""ll" "d"" for size=%" "zu""", offset, size); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 481, GF_LOG_TRACE, "NEW REQ at offset=%""ll" "d" " for size=%""zu""", offset, size); } while (0); |
482 | |
483 | fd_ctx_get (fd, this, &tmp_file); |
484 | file = (ra_file_t *)(long)tmp_file; |
485 | |
486 | if (!file || file->disabled) { |
487 | goto disabled; |
488 | } |
489 | |
490 | if (file->offset != offset) { |
491 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("unexpected offset (%""ll" "d"" != %" "ll" "d"") resetting", file->offset, offset); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__, 493, GF_LOG_TRACE , "unexpected offset (%""ll" "d"" != %""ll" "d"") resetting", file->offset, offset); } while (0) |
492 | "unexpected offset (%"PRId64" != %"PRId64") resetting",do { do { if (0) printf ("unexpected offset (%""ll" "d"" != %" "ll" "d"") resetting", file->offset, offset); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__, 493, GF_LOG_TRACE , "unexpected offset (%""ll" "d"" != %""ll" "d"") resetting", file->offset, offset); } while (0) |
493 | file->offset, offset)do { do { if (0) printf ("unexpected offset (%""ll" "d"" != %" "ll" "d"") resetting", file->offset, offset); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__, 493, GF_LOG_TRACE , "unexpected offset (%""ll" "d"" != %""ll" "d"") resetting", file->offset, offset); } while (0); |
494 | |
495 | expected_offset = file->expected = file->page_count = 0; |
496 | } else { |
497 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("expected offset (%""ll" "d"") when page_count=%d" , offset, file->page_count); } while (0); _gf_log (this-> name, "read-ahead.c", __FUNCTION__, 499, GF_LOG_TRACE, "expected offset (%" "ll" "d"") when page_count=%d", offset, file->page_count); } while (0) |
498 | "expected offset (%"PRId64") when page_count=%d",do { do { if (0) printf ("expected offset (%""ll" "d"") when page_count=%d" , offset, file->page_count); } while (0); _gf_log (this-> name, "read-ahead.c", __FUNCTION__, 499, GF_LOG_TRACE, "expected offset (%" "ll" "d"") when page_count=%d", offset, file->page_count); } while (0) |
499 | offset, file->page_count)do { do { if (0) printf ("expected offset (%""ll" "d"") when page_count=%d" , offset, file->page_count); } while (0); _gf_log (this-> name, "read-ahead.c", __FUNCTION__, 499, GF_LOG_TRACE, "expected offset (%" "ll" "d"") when page_count=%d", offset, file->page_count); } while (0); |
500 | |
501 | if (file->expected < (file->page_size * conf->page_count)) { |
502 | file->expected += size; |
503 | file->page_count = min ((file->expected(((file->expected / file->page_size))<(conf->page_count )?((file->expected / file->page_size)):(conf->page_count )) |
504 | / file->page_size),(((file->expected / file->page_size))<(conf->page_count )?((file->expected / file->page_size)):(conf->page_count )) |
505 | conf->page_count)(((file->expected / file->page_size))<(conf->page_count )?((file->expected / file->page_size)):(conf->page_count )); |
506 | } |
507 | } |
508 | |
509 | if (!expected_offset) { |
510 | flush_region (frame, file, 0, file->pages.prev->offset + 1, 0); |
511 | } |
512 | |
513 | local = mem_get0 (this->local_pool); |
514 | if (!local) { |
515 | op_errno = ENOMEM12; |
516 | goto unwind; |
517 | } |
518 | |
519 | local->fd = fd; |
520 | local->offset = offset; |
521 | local->size = size; |
522 | local->wait_count = 1; |
523 | |
524 | local->fill.next = &local->fill; |
525 | local->fill.prev = &local->fill; |
526 | |
527 | pthread_mutex_init (&local->local_lock, NULL((void*)0)); |
528 | |
529 | frame->local = local; |
530 | |
531 | dispatch_requests (frame, file); |
532 | |
533 | flush_region (frame, file, 0, floor (offset, file->page_size)(((offset)/((file->page_size)?(file->page_size):1))*(file ->page_size)), 0); |
534 | |
535 | read_ahead (frame, file); |
536 | |
537 | ra_frame_return (frame); |
538 | |
539 | file->offset = offset + size; |
540 | |
541 | return 0; |
542 | |
543 | unwind: |
544 | STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 545, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), 0, ((void*)0), ((void*)0), ((void*)0) ); (*__glusterfs_this_location()) = old_THIS; } while (0) |
545 | NULL)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 545, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), 0, ((void*)0), ((void*)0), ((void*)0) ); (*__glusterfs_this_location()) = old_THIS; } while (0); |
546 | |
547 | return 0; |
548 | |
549 | disabled: |
550 | STACK_WIND (frame, ra_readv_disabled_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 553, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_readv_disabled_cbk ; _new->root = frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_readv_disabled_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (frame->this->children->xlator); if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, (frame ->this->children->xlator)->fops->readv); (frame ->this->children->xlator)->fops->readv (_new, ( frame->this->children->xlator), fd, size, offset, flags , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
551 | FIRST_CHILD (frame->this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 553, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_readv_disabled_cbk ; _new->root = frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_readv_disabled_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (frame->this->children->xlator); if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, (frame ->this->children->xlator)->fops->readv); (frame ->this->children->xlator)->fops->readv (_new, ( frame->this->children->xlator), fd, size, offset, flags , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
552 | FIRST_CHILD (frame->this)->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 553, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_readv_disabled_cbk ; _new->root = frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_readv_disabled_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (frame->this->children->xlator); if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, (frame ->this->children->xlator)->fops->readv); (frame ->this->children->xlator)->fops->readv (_new, ( frame->this->children->xlator), fd, size, offset, flags , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
553 | fd, size, offset, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 553, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (frame->this ->children->xlator)->fops->readv_cbk) tmp_cbk = ra_readv_disabled_cbk ; _new->root = frame->root; _new->this = (frame-> this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD (frame->this)->fops->readv" ; _new->unwind_to = "ra_readv_disabled_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (frame->this->children->xlator); if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, (frame ->this->children->xlator)->fops->readv); (frame ->this->children->xlator)->fops->readv (_new, ( frame->this->children->xlator), fd, size, offset, flags , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); |
554 | return 0; |
555 | } |
556 | |
557 | |
558 | int |
559 | ra_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, |
560 | int32_t op_errno, dict_t *xdata) |
561 | { |
562 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 562, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
563 | STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, xdata)do { fop_flush_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 563, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_flush_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
564 | return 0; |
565 | } |
566 | |
567 | |
568 | |
569 | int |
570 | ra_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, |
571 | int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, |
572 | dict_t *xdata) |
573 | { |
574 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 574, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
575 | STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, prebuf, postbuf,do { fop_fsync_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 576, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsync_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
576 | xdata)do { fop_fsync_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 576, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsync_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
577 | return 0; |
578 | } |
579 | |
580 | |
581 | int |
582 | ra_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) |
583 | { |
584 | ra_file_t *file = NULL((void*)0); |
585 | uint64_t tmp_file = 0; |
586 | int32_t op_errno = EINVAL22; |
587 | |
588 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 588, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
589 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 589, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
590 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 590, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
591 | |
592 | fd_ctx_get (fd, this, &tmp_file); |
593 | |
594 | file = (ra_file_t *)(long)tmp_file; |
595 | if (file) { |
596 | flush_region (frame, file, 0, file->pages.prev->offset+1, 0); |
597 | } |
598 | |
599 | STACK_WIND (frame, ra_flush_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 600, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->flush_cbk) tmp_cbk = ra_flush_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->flush"; _new->unwind_to = "ra_flush_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->flush); (this->children->xlator )->fops->flush (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
600 | FIRST_CHILD (this)->fops->flush, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 600, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->flush_cbk) tmp_cbk = ra_flush_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->flush"; _new->unwind_to = "ra_flush_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->flush); (this->children->xlator )->fops->flush (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); |
601 | return 0; |
602 | |
603 | unwind: |
604 | STACK_UNWIND_STRICT (flush, frame, -1, op_errno, NULL)do { fop_flush_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 604, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_flush_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
605 | return 0; |
606 | } |
607 | |
608 | |
609 | int |
610 | ra_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync, |
611 | dict_t *xdata) |
612 | { |
613 | ra_file_t *file = NULL((void*)0); |
614 | uint64_t tmp_file = 0; |
615 | int32_t op_errno = EINVAL22; |
616 | |
617 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 617, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
618 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 618, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
619 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 619, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
620 | |
621 | fd_ctx_get (fd, this, &tmp_file); |
622 | |
623 | file = (ra_file_t *)(long)tmp_file; |
624 | if (file) { |
625 | flush_region (frame, file, 0, file->pages.prev->offset+1, 0); |
626 | } |
627 | |
628 | STACK_WIND (frame, ra_fsync_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 629, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsync_cbk) tmp_cbk = ra_fsync_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fsync"; _new->unwind_to = "ra_fsync_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsync); (this->children->xlator )->fops->fsync (_new, (this->children->xlator), fd , datasync, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
629 | FIRST_CHILD (this)->fops->fsync, fd, datasync, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 629, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsync_cbk) tmp_cbk = ra_fsync_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fsync"; _new->unwind_to = "ra_fsync_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsync); (this->children->xlator )->fops->fsync (_new, (this->children->xlator), fd , datasync, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
630 | return 0; |
631 | |
632 | unwind: |
633 | STACK_UNWIND_STRICT (fsync, frame, -1, op_errno, NULL, NULL, NULL)do { fop_fsync_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 633, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsync_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
634 | return 0; |
635 | } |
636 | |
637 | |
638 | int |
639 | ra_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
640 | int32_t op_ret, int32_t op_errno, struct iatt *prebuf, |
641 | struct iatt *postbuf, dict_t *xdata) |
642 | { |
643 | ra_file_t *file = NULL((void*)0); |
644 | |
645 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 645, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
646 | |
647 | file = frame->local; |
648 | |
649 | if (file) { |
650 | flush_region (frame, file, 0, file->pages.prev->offset+1, 1); |
651 | } |
652 | |
653 | frame->local = NULL((void*)0); |
654 | STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 655, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
655 | xdata)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 655, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
656 | return 0; |
657 | } |
658 | |
659 | |
660 | int |
661 | ra_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, |
662 | int32_t count, off_t offset, uint32_t flags, struct iobref *iobref, |
663 | dict_t *xdata) |
664 | { |
665 | ra_file_t *file = NULL((void*)0); |
666 | uint64_t tmp_file = 0; |
667 | int32_t op_errno = EINVAL22; |
668 | |
669 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 669, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
670 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 670, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
671 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 671, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
672 | |
673 | fd_ctx_get (fd, this, &tmp_file); |
674 | file = (ra_file_t *)(long)tmp_file; |
675 | if (file) { |
676 | flush_region (frame, file, 0, file->pages.prev->offset+1, 1); |
677 | frame->local = file; |
678 | /* reset the read-ahead counters too */ |
679 | file->expected = file->page_count = 0; |
680 | } |
681 | |
682 | STACK_WIND (frame, ra_writev_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 685, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = ra_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "ra_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
683 | FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 685, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = ra_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "ra_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
684 | FIRST_CHILD(this)->fops->writev,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 685, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = ra_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "ra_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
685 | fd, vector, count, offset, flags, iobref, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 685, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = ra_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "ra_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
686 | |
687 | return 0; |
688 | |
689 | unwind: |
690 | STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL, NULL)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 690, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
691 | return 0; |
692 | } |
693 | |
694 | |
695 | int |
696 | ra_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
697 | int32_t op_ret, int32_t op_errno, struct iatt *prebuf, |
698 | struct iatt *postbuf, dict_t *xdata) |
699 | { |
700 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 700, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
701 | |
702 | STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf,do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 703, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
703 | postbuf, xdata)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 703, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
704 | return 0; |
705 | } |
706 | |
707 | |
708 | int |
709 | ra_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
710 | int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata) |
711 | { |
712 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 712, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
713 | |
714 | STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, buf, xdata)do { fop_stat_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 714, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_stat_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, buf, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
715 | return 0; |
716 | } |
717 | |
718 | |
719 | int |
720 | ra_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, |
721 | dict_t *xdata) |
722 | { |
723 | ra_file_t *file = NULL((void*)0); |
724 | fd_t *iter_fd = NULL((void*)0); |
725 | inode_t *inode = NULL((void*)0); |
726 | uint64_t tmp_file = 0; |
727 | int32_t op_errno = EINVAL22; |
728 | |
729 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 729, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
730 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 730, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
731 | GF_VALIDATE_OR_GOTO (frame->this->name, loc, unwind)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 731, GF_LOG_ERROR, "invalid argument: " "loc"); } while (0); goto unwind; } } while (0); |
732 | |
733 | inode = loc->inode; |
734 | |
735 | LOCK (&inode->lock)pthread_spin_lock (&inode->lock); |
736 | { |
737 | list_for_each_entry (iter_fd, &inode->fd_list, inode_list)for (iter_fd = ((typeof(*iter_fd) *)((char *)((&inode-> fd_list)->next)-(unsigned long)(&((typeof(*iter_fd) *) 0)->inode_list))); &iter_fd->inode_list != (&inode ->fd_list); iter_fd = ((typeof(*iter_fd) *)((char *)(iter_fd ->inode_list.next)-(unsigned long)(&((typeof(*iter_fd) *)0)->inode_list)))) { |
738 | fd_ctx_get (iter_fd, this, &tmp_file); |
739 | file = (ra_file_t *)(long)tmp_file; |
740 | |
741 | if (!file) |
742 | continue; |
743 | /* |
744 | * Truncation invalidates reads just like writing does. |
745 | * TBD: this seems to flush more than it should. The |
746 | * only time we should flush at all is when we're |
747 | * shortening (not lengthening) the file, and then only |
748 | * from new EOF to old EOF. The same problem exists in |
749 | * ra_ftruncate. |
750 | */ |
751 | flush_region (frame, file, 0, |
752 | file->pages.prev->offset + 1, 1); |
753 | } |
754 | } |
755 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); |
756 | |
757 | STACK_WIND (frame, ra_truncate_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 760, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
758 | FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 760, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
759 | FIRST_CHILD (this)->fops->truncate,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 760, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
760 | loc, offset, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 760, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
761 | return 0; |
762 | |
763 | unwind: |
764 | STACK_UNWIND_STRICT (truncate, frame, -1, op_errno, NULL, NULL, NULL)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 764, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
765 | return 0; |
766 | } |
767 | |
768 | |
769 | void |
770 | ra_page_dump (struct ra_page *page) |
771 | { |
772 | int i = 0; |
773 | call_frame_t *frame = NULL((void*)0); |
774 | char key[GF_DUMP_MAX_BUF_LEN4096] = {0, }; |
775 | ra_waitq_t *trav = NULL((void*)0); |
776 | |
777 | if (page == NULL((void*)0)) { |
778 | goto out; |
779 | } |
780 | |
781 | gf_proc_dump_write ("offset", "%"PRId64"ll" "d", page->offset); |
782 | |
783 | gf_proc_dump_write ("size", "%"PRId64"ll" "d", page->size); |
784 | |
785 | gf_proc_dump_write ("dirty", "%s", page->dirty ? "yes" : "no"); |
786 | |
787 | gf_proc_dump_write ("poisoned", "%s", page->poisoned ? "yes" : "no"); |
788 | |
789 | gf_proc_dump_write ("ready", "%s", page->ready ? "yes" : "no"); |
790 | |
791 | for (trav = page->waitq; trav; trav = trav->next) { |
792 | frame = trav->data; |
793 | sprintf (key, "waiting-frame[%d]", i++); |
794 | gf_proc_dump_write (key, "%"PRId64"ll" "d", frame->root->unique); |
795 | } |
796 | |
797 | out: |
798 | return; |
799 | } |
800 | |
801 | int32_t |
802 | ra_fdctx_dump (xlator_t *this, fd_t *fd) |
803 | { |
804 | ra_file_t *file = NULL((void*)0); |
805 | ra_page_t *page = NULL((void*)0); |
806 | int32_t ret = 0, i = 0; |
807 | uint64_t tmp_file = 0; |
808 | char *path = NULL((void*)0); |
809 | char key[GF_DUMP_MAX_BUF_LEN4096] = {0, }; |
810 | char key_prefix[GF_DUMP_MAX_BUF_LEN4096] = {0, }; |
811 | |
812 | fd_ctx_get (fd, this, &tmp_file); |
813 | file = (ra_file_t *)(long)tmp_file; |
814 | |
815 | if (file == NULL((void*)0)) { |
816 | ret = 0; |
817 | goto out; |
818 | } |
819 | |
820 | gf_proc_dump_build_key (key_prefix,{ _gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead" , "file"); } |
821 | "xlator.performance.read-ahead",{ _gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead" , "file"); } |
822 | "file"){ _gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead" , "file"); }; |
823 | |
824 | gf_proc_dump_add_section (key_prefix); |
825 | |
826 | ret = __inode_path (fd->inode, NULL((void*)0), &path); |
Value stored to 'ret' is never read | |
827 | if (path != NULL((void*)0)) { |
828 | gf_proc_dump_write ("path", "%s", path); |
829 | GF_FREE (path)__gf_free (path); |
830 | } |
831 | |
832 | gf_proc_dump_write ("fd", "%p", fd); |
833 | |
834 | gf_proc_dump_write ("disabled", "%s", file->disabled ? "yes" : "no"); |
835 | |
836 | if (file->disabled) { |
837 | ret = 0; |
838 | goto out; |
839 | } |
840 | |
841 | gf_proc_dump_write ("page-size", "%"PRId64"ll" "d", file->page_size); |
842 | |
843 | gf_proc_dump_write ("page-count", "%u", file->page_count); |
844 | |
845 | gf_proc_dump_write ("next-expected-offset-for-sequential-reads", |
846 | "%"PRId64"ll" "d", file->offset); |
847 | |
848 | for (page = file->pages.next; page != &file->pages; |
849 | page = page->next) { |
850 | sprintf (key, "page[%d]", i); |
851 | gf_proc_dump_write (key, "%p", page[i++]); |
852 | ra_page_dump (page); |
853 | } |
854 | |
855 | ret = 0; |
856 | out: |
857 | return ret; |
858 | } |
859 | |
860 | int |
861 | ra_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) |
862 | { |
863 | ra_file_t *file = NULL((void*)0); |
864 | fd_t *iter_fd = NULL((void*)0); |
865 | inode_t *inode = NULL((void*)0); |
866 | uint64_t tmp_file = 0; |
867 | int32_t op_errno = EINVAL22; |
868 | |
869 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 869, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
870 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 870, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
871 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 871, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
872 | |
873 | inode = fd->inode; |
874 | |
875 | LOCK (&inode->lock)pthread_spin_lock (&inode->lock); |
876 | { |
877 | list_for_each_entry (iter_fd, &inode->fd_list, inode_list)for (iter_fd = ((typeof(*iter_fd) *)((char *)((&inode-> fd_list)->next)-(unsigned long)(&((typeof(*iter_fd) *) 0)->inode_list))); &iter_fd->inode_list != (&inode ->fd_list); iter_fd = ((typeof(*iter_fd) *)((char *)(iter_fd ->inode_list.next)-(unsigned long)(&((typeof(*iter_fd) *)0)->inode_list)))) { |
878 | fd_ctx_get (iter_fd, this, &tmp_file); |
879 | file = (ra_file_t *)(long)tmp_file; |
880 | |
881 | if (!file) |
882 | continue; |
883 | flush_region (frame, file, 0, |
884 | file->pages.prev->offset + 1, 0); |
885 | } |
886 | } |
887 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); |
888 | |
889 | STACK_WIND (frame, ra_attr_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 890, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fstat_cbk) tmp_cbk = ra_attr_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fstat"; _new->unwind_to = "ra_attr_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fstat); (this->children->xlator )->fops->fstat (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
890 | FIRST_CHILD (this)->fops->fstat, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 890, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fstat_cbk) tmp_cbk = ra_attr_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fstat"; _new->unwind_to = "ra_attr_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fstat); (this->children->xlator )->fops->fstat (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); |
891 | return 0; |
892 | |
893 | unwind: |
894 | STACK_UNWIND_STRICT (stat, frame, -1, op_errno, NULL, NULL)do { fop_stat_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 894, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_stat_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
895 | return 0; |
896 | } |
897 | |
898 | |
899 | int |
900 | ra_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, |
901 | dict_t *xdata) |
902 | { |
903 | ra_file_t *file = NULL((void*)0); |
904 | fd_t *iter_fd = NULL((void*)0); |
905 | inode_t *inode = NULL((void*)0); |
906 | uint64_t tmp_file = 0; |
907 | int32_t op_errno = EINVAL22; |
908 | |
909 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "read-ahead.c" , __FUNCTION__, 909, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
910 | GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 910, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); |
911 | GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (frame->this->name, "read-ahead.c", __FUNCTION__, 911, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto unwind ; } } while (0); |
912 | |
913 | inode = fd->inode; |
914 | |
915 | LOCK (&inode->lock)pthread_spin_lock (&inode->lock); |
916 | { |
917 | list_for_each_entry (iter_fd, &inode->fd_list, inode_list)for (iter_fd = ((typeof(*iter_fd) *)((char *)((&inode-> fd_list)->next)-(unsigned long)(&((typeof(*iter_fd) *) 0)->inode_list))); &iter_fd->inode_list != (&inode ->fd_list); iter_fd = ((typeof(*iter_fd) *)((char *)(iter_fd ->inode_list.next)-(unsigned long)(&((typeof(*iter_fd) *)0)->inode_list)))) { |
918 | fd_ctx_get (iter_fd, this, &tmp_file); |
919 | file = (ra_file_t *)(long)tmp_file; |
920 | if (!file) |
921 | continue; |
922 | /* |
923 | * Truncation invalidates reads just like writing does. |
924 | * TBD: this seems to flush more than it should. The |
925 | * only time we should flush at all is when we're |
926 | * shortening (not lengthening) the file, and then only |
927 | * from new EOF to old EOF. The same problem exists in |
928 | * ra_truncate. |
929 | */ |
930 | flush_region (frame, file, 0, |
931 | file->pages.prev->offset + 1, 1); |
932 | } |
933 | } |
934 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); |
935 | |
936 | STACK_WIND (frame, ra_truncate_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 937, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->ftruncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), fd, offset, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
937 | FIRST_CHILD (this)->fops->ftruncate, fd, offset, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "read-ahead.c", __FUNCTION__, 937, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = ra_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->ftruncate" ; _new->unwind_to = "ra_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), fd, offset, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); |
938 | return 0; |
939 | |
940 | unwind: |
941 | STACK_UNWIND_STRICT (truncate, frame, -1, op_errno, NULL, NULL, NULL)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "read-ahead.c", __FUNCTION__, 941, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
942 | return 0; |
943 | } |
944 | |
945 | |
946 | int |
947 | ra_priv_dump (xlator_t *this) |
948 | { |
949 | ra_conf_t *conf = NULL((void*)0); |
950 | int ret = -1; |
951 | char key_prefix[GF_DUMP_MAX_BUF_LEN4096] = {0, }; |
952 | gf_boolean_t add_section = _gf_false; |
953 | |
954 | if (!this) { |
955 | goto out; |
956 | } |
957 | |
958 | conf = this->private; |
959 | if (!conf) { |
960 | gf_log (this->name, GF_LOG_WARNING, "conf null in xlator")do { do { if (0) printf ("conf null in xlator"); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__, 960, GF_LOG_WARNING , "conf null in xlator"); } while (0); |
961 | goto out; |
962 | } |
963 | |
964 | gf_proc_dump_build_key (key_prefix, "xlator.performance.read-ahead",{ _gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead" , "priv"); } |
965 | "priv"){ _gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead" , "priv"); }; |
966 | |
967 | gf_proc_dump_add_section (key_prefix); |
968 | add_section = _gf_true; |
969 | |
970 | ret = pthread_mutex_trylock (&conf->conf_lock); |
971 | if (ret) |
972 | goto out; |
973 | { |
974 | gf_proc_dump_write ("page_size", "%d", conf->page_size); |
975 | gf_proc_dump_write ("page_count", "%d", conf->page_count); |
976 | gf_proc_dump_write ("force_atime_update", "%d", |
977 | conf->force_atime_update); |
978 | } |
979 | pthread_mutex_unlock (&conf->conf_lock); |
980 | |
981 | ret = 0; |
982 | out: |
983 | if (ret && conf) { |
984 | if (add_section == _gf_false) |
985 | gf_proc_dump_add_section (key_prefix); |
986 | |
987 | gf_proc_dump_write ("Unable to dump priv", |
988 | "(Lock acquisition failed) %s", this->name); |
989 | } |
990 | return ret; |
991 | } |
992 | |
993 | |
994 | int32_t |
995 | mem_acct_init (xlator_t *this) |
996 | { |
997 | int ret = -1; |
998 | |
999 | if (!this) { |
1000 | goto out; |
1001 | } |
1002 | |
1003 | ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1); |
1004 | |
1005 | if (ret != 0) { |
1006 | gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"do { do { if (0) printf ("Memory accounting init" "failed"); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1007, GF_LOG_ERROR, "Memory accounting init" "failed"); } while (0) |
1007 | "failed")do { do { if (0) printf ("Memory accounting init" "failed"); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1007, GF_LOG_ERROR, "Memory accounting init" "failed"); } while (0); |
1008 | } |
1009 | |
1010 | out: |
1011 | return ret; |
1012 | } |
1013 | |
1014 | int |
1015 | reconfigure (xlator_t *this, dict_t *options) |
1016 | { |
1017 | ra_conf_t *conf = NULL((void*)0); |
1018 | int ret = -1; |
1019 | |
1020 | GF_VALIDATE_OR_GOTO ("read-ahead", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 1020, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); |
1021 | GF_VALIDATE_OR_GOTO ("read-ahead", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c" , __FUNCTION__, 1021, GF_LOG_ERROR, "invalid argument: " "this->private" ); } while (0); goto out; } } while (0); |
1022 | |
1023 | conf = this->private; |
1024 | |
1025 | GF_OPTION_RECONF ("page-count", conf->page_count, options, uint32, out)do { int val_ret = 0; val_ret = xlator_option_reconf_uint32 ( (*__glusterfs_this_location()), options, "page-count", &( conf->page_count)); if (val_ret) goto out; } while (0); |
1026 | |
1027 | GF_OPTION_RECONF ("page-size", conf->page_size, options, size, out)do { int val_ret = 0; val_ret = xlator_option_reconf_size ((* __glusterfs_this_location()), options, "page-size", &(conf ->page_size)); if (val_ret) goto out; } while (0); |
1028 | |
1029 | ret = 0; |
1030 | out: |
1031 | return ret; |
1032 | } |
1033 | |
1034 | int |
1035 | init (xlator_t *this) |
1036 | { |
1037 | ra_conf_t *conf = NULL((void*)0); |
1038 | int32_t ret = -1; |
1039 | |
1040 | GF_VALIDATE_OR_GOTO ("read-ahead", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 1040, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); |
1041 | |
1042 | if (!this->children || this->children->next) { |
1043 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("FATAL: read-ahead not configured with exactly one" " child"); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 1045, GF_LOG_ERROR, "FATAL: read-ahead not configured with exactly one" " child"); } while (0) |
1044 | "FATAL: read-ahead not configured with exactly one"do { do { if (0) printf ("FATAL: read-ahead not configured with exactly one" " child"); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 1045, GF_LOG_ERROR, "FATAL: read-ahead not configured with exactly one" " child"); } while (0) |
1045 | " child")do { do { if (0) printf ("FATAL: read-ahead not configured with exactly one" " child"); } while (0); _gf_log (this->name, "read-ahead.c" , __FUNCTION__, 1045, GF_LOG_ERROR, "FATAL: read-ahead not configured with exactly one" " child"); } while (0); |
1046 | goto out; |
1047 | } |
1048 | |
1049 | if (!this->parents) { |
1050 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dangling volume. check volfile "); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1051, GF_LOG_WARNING, "dangling volume. check volfile "); } while (0) |
1051 | "dangling volume. check volfile ")do { do { if (0) printf ("dangling volume. check volfile "); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1051, GF_LOG_WARNING, "dangling volume. check volfile "); } while (0); |
1052 | } |
1053 | |
1054 | conf = (void *) GF_CALLOC (1, sizeof (*conf), gf_ra_mt_ra_conf_t)__gf_calloc (1, sizeof (*conf), gf_ra_mt_ra_conf_t); |
1055 | if (conf == NULL((void*)0)) { |
1056 | goto out; |
1057 | } |
1058 | |
1059 | conf->page_size = this->ctx->page_size; |
1060 | |
1061 | GF_OPTION_INIT ("page-size", conf->page_size, size, out)do { int val_ret = 0; val_ret = xlator_option_init_size ((*__glusterfs_this_location ()), (*__glusterfs_this_location())->options, "page-size", &(conf->page_size)); if (val_ret) goto out; } while ( 0); |
1062 | |
1063 | GF_OPTION_INIT ("page-count", conf->page_count, uint32, out)do { int val_ret = 0; val_ret = xlator_option_init_uint32 ((* __glusterfs_this_location()), (*__glusterfs_this_location())-> options, "page-count", &(conf->page_count)); if (val_ret ) goto out; } while (0); |
1064 | |
1065 | GF_OPTION_INIT ("force-atime-update", conf->force_atime_update, bool, out)do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location ()), (*__glusterfs_this_location())->options, "force-atime-update" , &(conf->force_atime_update)); if (val_ret) goto out; } while (0); |
1066 | |
1067 | conf->files.next = &conf->files; |
1068 | conf->files.prev = &conf->files; |
1069 | |
1070 | pthread_mutex_init (&conf->conf_lock, NULL((void*)0)); |
1071 | |
1072 | this->local_pool = mem_pool_new (ra_local_t, 64)mem_pool_new_fn (sizeof(ra_local_t), 64, "ra_local_t"); |
1073 | if (!this->local_pool) { |
1074 | ret = -1; |
1075 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to create local_t's memory pool" ); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1076, GF_LOG_ERROR, "failed to create local_t's memory pool" ); } while (0) |
1076 | "failed to create local_t's memory pool")do { do { if (0) printf ("failed to create local_t's memory pool" ); } while (0); _gf_log (this->name, "read-ahead.c", __FUNCTION__ , 1076, GF_LOG_ERROR, "failed to create local_t's memory pool" ); } while (0); |
1077 | goto out; |
1078 | } |
1079 | |
1080 | this->private = conf; |
1081 | ret = 0; |
1082 | |
1083 | out: |
1084 | if (ret == -1) { |
1085 | GF_FREE (conf)__gf_free (conf); |
1086 | } |
1087 | |
1088 | return ret; |
1089 | } |
1090 | |
1091 | |
1092 | void |
1093 | fini (xlator_t *this) |
1094 | { |
1095 | ra_conf_t *conf = NULL((void*)0); |
1096 | |
1097 | GF_VALIDATE_OR_GOTO ("read-ahead", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("read-ahead", "read-ahead.c", __FUNCTION__, 1097, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); |
1098 | |
1099 | conf = this->private; |
1100 | if (conf == NULL((void*)0)) { |
1101 | goto out; |
1102 | } |
1103 | |
1104 | this->private = NULL((void*)0); |
1105 | |
1106 | GF_ASSERT ((conf->files.next == &conf->files)do { if (!((conf->files.next == &conf->files) && (conf->files.prev == &conf->files))) { do { do { if (0) printf ("Assertion failed: " "(conf->files.next == &conf->files) && (conf->files.prev == &conf->files)" ); } while (0); _gf_log_callingfn ("", "read-ahead.c", __FUNCTION__ , 1107, GF_LOG_ERROR, "Assertion failed: " "(conf->files.next == &conf->files) && (conf->files.prev == &conf->files)" ); } while (0); } } while (0) |
1107 | && (conf->files.prev == &conf->files))do { if (!((conf->files.next == &conf->files) && (conf->files.prev == &conf->files))) { do { do { if (0) printf ("Assertion failed: " "(conf->files.next == &conf->files) && (conf->files.prev == &conf->files)" ); } while (0); _gf_log_callingfn ("", "read-ahead.c", __FUNCTION__ , 1107, GF_LOG_ERROR, "Assertion failed: " "(conf->files.next == &conf->files) && (conf->files.prev == &conf->files)" ); } while (0); } } while (0); |
1108 | |
1109 | pthread_mutex_destroy (&conf->conf_lock); |
1110 | GF_FREE (conf)__gf_free (conf); |
1111 | |
1112 | out: |
1113 | return; |
1114 | } |
1115 | |
1116 | struct xlator_fops fops = { |
1117 | .open = ra_open, |
1118 | .create = ra_create, |
1119 | .readv = ra_readv, |
1120 | .writev = ra_writev, |
1121 | .flush = ra_flush, |
1122 | .fsync = ra_fsync, |
1123 | .truncate = ra_truncate, |
1124 | .ftruncate = ra_ftruncate, |
1125 | .fstat = ra_fstat, |
1126 | }; |
1127 | |
1128 | struct xlator_cbks cbks = { |
1129 | .release = ra_release, |
1130 | }; |
1131 | |
1132 | struct xlator_dumpops dumpops = { |
1133 | .priv = ra_priv_dump, |
1134 | .fdctx = ra_fdctx_dump, |
1135 | }; |
1136 | |
1137 | struct volume_options options[] = { |
1138 | { .key = {"force-atime-update"}, |
1139 | .type = GF_OPTION_TYPE_BOOL, |
1140 | .default_value = "false" |
1141 | }, |
1142 | { .key = {"page-count"}, |
1143 | .type = GF_OPTION_TYPE_INT, |
1144 | .min = 1, |
1145 | .max = 16, |
1146 | .default_value = "4", |
1147 | .description = "Number of pages that will be pre-fetched" |
1148 | }, |
1149 | { .key = {"page-size"}, |
1150 | .type = GF_OPTION_TYPE_SIZET, |
1151 | .min = 4096, |
1152 | .max = 1048576 * 64, |
1153 | .default_value = "131072", |
1154 | .description = "Page size with which read-ahead performs server I/O" |
1155 | }, |
1156 | { .key = {NULL((void*)0)} }, |
1157 | }; |