~ubuntu-branches/ubuntu/trusty/linux-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to zfs/module/zfs/dmu_traverse.c

  • Committer: Package Import Robot
  • Author(s): Brad Figg
  • Date: 2016-03-17 09:18:22 UTC
  • Revision ID: package-import@ubuntu.com-20160317091822-1sqft3zxoyt9tumu
Tags: 4.4.0-14.30~14.04.2
* Release Tracking Bug (LP: #1558247)

* Current 4.4 kernel won't boot on powerpc (LP: #1557130)
  - powerpc: Fix dedotify for binutils >= 2.26

* ZFS: send fails to transmit some holes [corruption] (LP: #1557151)
  - Illumos 6370 - ZFS send fails to transmit some holes

* Request to cherry-pick uvcvideo patch for Xenial kernel support of RealSense
  camera (LP: #1557138)
  - UVC: Add support for ds4 depth camera

* use after free of task_struct->numa_faults in task_numa_find_cpu (LP: #1527643)
  - sched/numa: Fix use-after-free bug in the task_numa_compare

* overlay fs regression: chmod fails with "Operation not permitted" on chowned
  files (LP: #1555997)
  - ovl: copy new uid/gid into overlayfs runtime inode

* Miscellaneous Ubuntu changes
  - SAUCE: Dump stack when X.509 certificates cannot be loaded

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
/*
22
22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23
 
 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
 
23
 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
24
24
 */
25
25
 
26
26
#include <sys/zfs_context.h>
61
61
        uint64_t td_hole_birth_enabled_txg;
62
62
        blkptr_cb_t *td_func;
63
63
        void *td_arg;
 
64
        boolean_t td_realloc_possible;
64
65
} traverse_data_t;
65
66
 
66
67
static int traverse_dnode(traverse_data_t *td, const dnode_phys_t *dnp,
228
229
 
229
230
        if (bp->blk_birth == 0) {
230
231
                /*
231
 
                 * Since this block has a birth time of 0 it must be a
232
 
                 * hole created before the SPA_FEATURE_HOLE_BIRTH
233
 
                 * feature was enabled.  If SPA_FEATURE_HOLE_BIRTH
234
 
                 * was enabled before the min_txg for this traveral we
235
 
                 * know the hole must have been created before the
236
 
                 * min_txg for this traveral, so we can skip it. If
237
 
                 * SPA_FEATURE_HOLE_BIRTH was enabled after the min_txg
238
 
                 * for this traveral we cannot tell if the hole was
239
 
                 * created before or after the min_txg for this
240
 
                 * traversal, so we cannot skip it.
 
232
                 * Since this block has a birth time of 0 it must be one of
 
233
                 * two things: a hole created before the
 
234
                 * SPA_FEATURE_HOLE_BIRTH feature was enabled, or a hole
 
235
                 * which has always been a hole in an object.
 
236
                 *
 
237
                 * If a file is written sparsely, then the unwritten parts of
 
238
                 * the file were "always holes" -- that is, they have been
 
239
                 * holes since this object was allocated.  However, we (and
 
240
                 * our callers) can not necessarily tell when an object was
 
241
                 * allocated.  Therefore, if it's possible that this object
 
242
                 * was freed and then its object number reused, we need to
 
243
                 * visit all the holes with birth==0.
 
244
                 *
 
245
                 * If it isn't possible that the object number was reused,
 
246
                 * then if SPA_FEATURE_HOLE_BIRTH was enabled before we wrote
 
247
                 * all the blocks we will visit as part of this traversal,
 
248
                 * then this hole must have always existed, so we can skip
 
249
                 * it.  We visit blocks born after (exclusive) td_min_txg.
 
250
                 *
 
251
                 * Note that the meta-dnode cannot be reallocated.
241
252
                 */
242
 
                if (td->td_hole_birth_enabled_txg < td->td_min_txg)
 
253
                if ((!td->td_realloc_possible ||
 
254
                        zb->zb_object == DMU_META_DNODE_OBJECT) &&
 
255
                        td->td_hole_birth_enabled_txg <= td->td_min_txg)
243
256
                        return (0);
244
257
        } else if (bp->blk_birth <= td->td_min_txg) {
245
258
                return (0);
347
360
 
348
361
                prefetch_dnode_metadata(td, mdnp, zb->zb_objset,
349
362
                    DMU_META_DNODE_OBJECT);
 
363
                /*
 
364
                 * See the block comment above for the goal of this variable.
 
365
                 * If the maxblkid of the meta-dnode is 0, then we know that
 
366
                 * we've never had more than DNODES_PER_BLOCK objects in the
 
367
                 * dataset, which means we can't have reused any object ids.
 
368
                 */
 
369
                if (osp->os_meta_dnode.dn_maxblkid == 0)
 
370
                        td->td_realloc_possible = B_FALSE;
 
371
 
350
372
                if (arc_buf_size(buf) >= sizeof (objset_phys_t)) {
351
373
                        prefetch_dnode_metadata(td, gdnp, zb->zb_objset,
352
374
                            DMU_GROUPUSED_OBJECT);
530
552
        td->td_pfd = pd;
531
553
        td->td_flags = flags;
532
554
        td->td_paused = B_FALSE;
 
555
        td->td_realloc_possible = (txg_start == 0 ? B_FALSE : B_TRUE);
533
556
 
534
557
        if (spa_feature_is_active(spa, SPA_FEATURE_HOLE_BIRTH)) {
535
558
                VERIFY(spa_feature_enabled_txg(spa,
536
559
                    SPA_FEATURE_HOLE_BIRTH, &td->td_hole_birth_enabled_txg));
537
560
        } else {
538
 
                td->td_hole_birth_enabled_txg = 0;
 
561
                td->td_hole_birth_enabled_txg = UINT64_MAX;
539
562
        }
540
563
 
541
564
        pd->pd_flags = flags;