| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nilfs_vnops.c,v 1.16.6.1 2012/08/12 12:59:47 martin Exp $ */ | | 1 | /* $NetBSD: nilfs_vnops.c,v 1.16.6.1.4.1 2013/06/13 10:53:00 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2008, 2009 Reinoud Zandijk | | 4 | * Copyright (c) 2008, 2009 Reinoud Zandijk |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -18,27 +18,27 @@ | | | @@ -18,27 +18,27 @@ |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | | 26 | * |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | #ifndef lint | | 30 | #ifndef lint |
31 | __KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.16.6.1 2012/08/12 12:59:47 martin Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.16.6.1.4.1 2013/06/13 10:53:00 msaitoh Exp $"); |
32 | #endif /* not lint */ | | 32 | #endif /* not lint */ |
33 | | | 33 | |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/namei.h> | | 37 | #include <sys/namei.h> |
38 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | | 38 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/file.h> /* define FWRITE ... */ | | 40 | #include <sys/file.h> /* define FWRITE ... */ |
41 | #include <sys/stat.h> | | 41 | #include <sys/stat.h> |
42 | #include <sys/buf.h> | | 42 | #include <sys/buf.h> |
43 | #include <sys/proc.h> | | 43 | #include <sys/proc.h> |
44 | #include <sys/mount.h> | | 44 | #include <sys/mount.h> |
| @@ -305,26 +305,31 @@ return EIO; | | | @@ -305,26 +305,31 @@ return EIO; |
305 | if ((resid > uio->uio_resid) && ((ioflag & IO_SYNC) == IO_SYNC)) | | 305 | if ((resid > uio->uio_resid) && ((ioflag & IO_SYNC) == IO_SYNC)) |
306 | error = nilfs_update(vp, NULL, NULL, NULL, UPDATE_WAIT); | | 306 | error = nilfs_update(vp, NULL, NULL, NULL, UPDATE_WAIT); |
307 | } | | 307 | } |
308 | | | 308 | |
309 | return error; | | 309 | return error; |
310 | } | | 310 | } |
311 | | | 311 | |
312 | | | 312 | |
313 | /* --------------------------------------------------------------------- */ | | 313 | /* --------------------------------------------------------------------- */ |
314 | | | 314 | |
315 | /* | | 315 | /* |
316 | * bmap functionality that translates logical block numbers to the virtual | | 316 | * bmap functionality that translates logical block numbers to the virtual |
317 | * block numbers to be stored on the vnode itself. | | 317 | * block numbers to be stored on the vnode itself. |
| | | 318 | * |
| | | 319 | * Important alert! |
| | | 320 | * |
| | | 321 | * If runp is not NULL, the number of contiguous blocks __starting from the |
| | | 322 | * next block after the queried block__ will be returned in runp. |
318 | */ | | 323 | */ |
319 | | | 324 | |
320 | int | | 325 | int |
321 | nilfs_trivial_bmap(void *v) | | 326 | nilfs_trivial_bmap(void *v) |
322 | { | | 327 | { |
323 | struct vop_bmap_args /* { | | 328 | struct vop_bmap_args /* { |
324 | struct vnode *a_vp; | | 329 | struct vnode *a_vp; |
325 | daddr_t a_bn; | | 330 | daddr_t a_bn; |
326 | struct vnode **a_vpp; | | 331 | struct vnode **a_vpp; |
327 | daddr_t *a_bnp; | | 332 | daddr_t *a_bnp; |
328 | int *a_runp; | | 333 | int *a_runp; |
329 | } */ *ap = v; | | 334 | } */ *ap = v; |
330 | struct vnode *vp = ap->a_vp; /* our node */ | | 335 | struct vnode *vp = ap->a_vp; /* our node */ |
| @@ -354,27 +359,28 @@ nilfs_trivial_bmap(void *v) | | | @@ -354,27 +359,28 @@ nilfs_trivial_bmap(void *v) |
354 | } | | 359 | } |
355 | | | 360 | |
356 | /* store virtual blocks on our own vp */ | | 361 | /* store virtual blocks on our own vp */ |
357 | if (vpp) | | 362 | if (vpp) |
358 | *vpp = vp; | | 363 | *vpp = vp; |
359 | | | 364 | |
360 | /* start at virt[0] */ | | 365 | /* start at virt[0] */ |
361 | *bnp = l2vmap[0]; | | 366 | *bnp = l2vmap[0]; |
362 | | | 367 | |
363 | /* get runlength */ | | 368 | /* get runlength */ |
364 | run = 1; | | 369 | run = 1; |
365 | while ((run < blks) && (l2vmap[run] == *bnp + run)) | | 370 | while ((run < blks) && (l2vmap[run] == *bnp + run)) |
366 | run++; | | 371 | run++; |
367 | | | 372 | run--; /* see comment at start of function */ |
| | | 373 | |
368 | /* set runlength */ | | 374 | /* set runlength */ |
369 | if (runp) | | 375 | if (runp) |
370 | *runp = run; | | 376 | *runp = run; |
371 | | | 377 | |
372 | DPRINTF(TRANSLATE, ("\tstart %"PRIu64" -> %"PRIu64" run %d\n", | | 378 | DPRINTF(TRANSLATE, ("\tstart %"PRIu64" -> %"PRIu64" run %d\n", |
373 | bn, *bnp, run)); | | 379 | bn, *bnp, run)); |
374 | | | 380 | |
375 | /* mark not translated on virtual block number 0 */ | | 381 | /* mark not translated on virtual block number 0 */ |
376 | if (*bnp == 0) | | 382 | if (*bnp == 0) |
377 | *bnp = -1; | | 383 | *bnp = -1; |
378 | | | 384 | |
379 | /* return success */ | | 385 | /* return success */ |
380 | free(l2vmap, M_TEMP); | | 386 | free(l2vmap, M_TEMP); |