aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/blocklayout/blocklayout.c6
-rw-r--r--fs/nfs/blocklayout/blocklayout.h3
-rw-r--r--fs/nfs/blocklayout/extents.c76
3 files changed, 8 insertions, 77 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index baf0bf2acbd4..a263810803c1 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -577,8 +577,7 @@ fill_invalid_ext:
577 unlock_page(page); 577 unlock_page(page);
578 578
579 ret = bl_mark_sectors_init(be->be_inval, isect, 579 ret = bl_mark_sectors_init(be->be_inval, isect,
580 PAGE_CACHE_SECTORS, 580 PAGE_CACHE_SECTORS);
581 NULL);
582 if (unlikely(ret)) { 581 if (unlikely(ret)) {
583 dprintk("%s bl_mark_sectors_init fail %d\n", 582 dprintk("%s bl_mark_sectors_init fail %d\n",
584 __func__, ret); 583 __func__, ret);
@@ -627,8 +626,7 @@ next_page:
627 } 626 }
628 if (be->be_state == PNFS_BLOCK_INVALID_DATA) { 627 if (be->be_state == PNFS_BLOCK_INVALID_DATA) {
629 ret = bl_mark_sectors_init(be->be_inval, isect, 628 ret = bl_mark_sectors_init(be->be_inval, isect,
630 PAGE_CACHE_SECTORS, 629 PAGE_CACHE_SECTORS);
631 NULL);
632 if (unlikely(ret)) { 630 if (unlikely(ret)) {
633 dprintk("%s bl_mark_sectors_init fail %d\n", 631 dprintk("%s bl_mark_sectors_init fail %d\n",
634 __func__, ret); 632 __func__, ret);
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
index 42acf7ef5992..60728acc7b99 100644
--- a/fs/nfs/blocklayout/blocklayout.h
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -186,8 +186,7 @@ struct pnfs_block_extent *
186bl_find_get_extent(struct pnfs_block_layout *bl, sector_t isect, 186bl_find_get_extent(struct pnfs_block_layout *bl, sector_t isect,
187 struct pnfs_block_extent **cow_read); 187 struct pnfs_block_extent **cow_read);
188int bl_mark_sectors_init(struct pnfs_inval_markings *marks, 188int bl_mark_sectors_init(struct pnfs_inval_markings *marks,
189 sector_t offset, sector_t length, 189 sector_t offset, sector_t length);
190 sector_t **pages);
191void bl_put_extent(struct pnfs_block_extent *be); 190void bl_put_extent(struct pnfs_block_extent *be);
192struct pnfs_block_extent *bl_alloc_extent(void); 191struct pnfs_block_extent *bl_alloc_extent(void);
193int bl_is_sector_init(struct pnfs_inval_markings *marks, sector_t isect); 192int bl_is_sector_init(struct pnfs_inval_markings *marks, sector_t isect);
diff --git a/fs/nfs/blocklayout/extents.c b/fs/nfs/blocklayout/extents.c
index 369ef53e89e1..d0f52ed22428 100644
--- a/fs/nfs/blocklayout/extents.c
+++ b/fs/nfs/blocklayout/extents.c
@@ -174,33 +174,6 @@ static int _preload_range(struct pnfs_inval_markings *marks,
174 return status; 174 return status;
175} 175}
176 176
177static void set_needs_init(sector_t *array, sector_t offset)
178{
179 sector_t *p = array;
180
181 dprintk("%s enter\n", __func__);
182 if (!p)
183 return;
184 while (*p < offset)
185 p++;
186 if (*p == offset)
187 return;
188 else if (*p == ~0) {
189 *p++ = offset;
190 *p = ~0;
191 return;
192 } else {
193 sector_t *save = p;
194 dprintk("%s Adding %llu\n", __func__, (u64)offset);
195 while (*p != ~0)
196 p++;
197 p++;
198 memmove(save + 1, save, (char *)p - (char *)save);
199 *save = offset;
200 return;
201 }
202}
203
204/* We are relying on page lock to serialize this */ 177/* We are relying on page lock to serialize this */
205int bl_is_sector_init(struct pnfs_inval_markings *marks, sector_t isect) 178int bl_is_sector_init(struct pnfs_inval_markings *marks, sector_t isect)
206{ 179{
@@ -256,28 +229,15 @@ static int is_range_written(struct pnfs_inval_markings *marks,
256 229
257/* Marks sectors in [offest, offset_length) as having been initialized. 230/* Marks sectors in [offest, offset_length) as having been initialized.
258 * All lengths are step-aligned, where step is min(pagesize, blocksize). 231 * All lengths are step-aligned, where step is min(pagesize, blocksize).
259 * Notes where partial block is initialized, and helps prepare it for 232 * Currently assumes offset is page-aligned
260 * complete initialization later.
261 */ 233 */
262/* Currently assumes offset is page-aligned */
263int bl_mark_sectors_init(struct pnfs_inval_markings *marks, 234int bl_mark_sectors_init(struct pnfs_inval_markings *marks,
264 sector_t offset, sector_t length, 235 sector_t offset, sector_t length)
265 sector_t **pages)
266{ 236{
267 sector_t s, start, end; 237 sector_t start, end;
268 sector_t *array = NULL; /* Pages to mark */
269 238
270 dprintk("%s(offset=%llu,len=%llu) enter\n", 239 dprintk("%s(offset=%llu,len=%llu) enter\n",
271 __func__, (u64)offset, (u64)length); 240 __func__, (u64)offset, (u64)length);
272 s = max((sector_t) 3,
273 2 * (marks->im_block_size / (PAGE_CACHE_SECTORS)));
274 dprintk("%s set max=%llu\n", __func__, (u64)s);
275 if (pages) {
276 array = kmalloc(s * sizeof(sector_t), GFP_NOFS);
277 if (!array)
278 goto outerr;
279 array[0] = ~0;
280 }
281 241
282 start = normalize(offset, marks->im_block_size); 242 start = normalize(offset, marks->im_block_size);
283 end = normalize_up(offset + length, marks->im_block_size); 243 end = normalize_up(offset + length, marks->im_block_size);
@@ -285,41 +245,15 @@ int bl_mark_sectors_init(struct pnfs_inval_markings *marks,
285 goto outerr; 245 goto outerr;
286 246
287 spin_lock(&marks->im_lock); 247 spin_lock(&marks->im_lock);
288
289 for (s = normalize_up(start, PAGE_CACHE_SECTORS);
290 s < offset; s += PAGE_CACHE_SECTORS) {
291 dprintk("%s pre-area pages\n", __func__);
292 /* Portion of used block is not initialized */
293 if (!_has_tag(&marks->im_tree, s, EXTENT_INITIALIZED))
294 set_needs_init(array, s);
295 }
296 if (_set_range(&marks->im_tree, EXTENT_INITIALIZED, offset, length)) 248 if (_set_range(&marks->im_tree, EXTENT_INITIALIZED, offset, length))
297 goto out_unlock; 249 goto out_unlock;
298 for (s = normalize_up(offset + length, PAGE_CACHE_SECTORS);
299 s < end; s += PAGE_CACHE_SECTORS) {
300 dprintk("%s post-area pages\n", __func__);
301 if (!_has_tag(&marks->im_tree, s, EXTENT_INITIALIZED))
302 set_needs_init(array, s);
303 }
304
305 spin_unlock(&marks->im_lock); 250 spin_unlock(&marks->im_lock);
306 251
307 if (pages) {
308 if (array[0] == ~0) {
309 kfree(array);
310 *pages = NULL;
311 } else
312 *pages = array;
313 }
314 return 0; 252 return 0;
315 253
316 out_unlock: 254out_unlock:
317 spin_unlock(&marks->im_lock); 255 spin_unlock(&marks->im_lock);
318 outerr: 256outerr:
319 if (pages) {
320 kfree(array);
321 *pages = NULL;
322 }
323 return -ENOMEM; 257 return -ENOMEM;
324} 258}
325 259