]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'dev/gfp-flags' into for-next-4.6-20160203
authorDavid Sterba <dsterba@suse.com>
Wed, 3 Feb 2016 09:22:31 +0000 (10:22 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 3 Feb 2016 09:22:31 +0000 (10:22 +0100)
1  2 
fs/btrfs/scrub.c
fs/btrfs/send.c

diff --combined fs/btrfs/scrub.c
index b1a68530e9119515218d2b09770b2654ea40728b,6f722d88d37cd576635386f66bd65e9f576bdaa2..1441f1217cf76d87a0d61cb50001cecf9686351a
@@@ -461,7 -461,7 +461,7 @@@ struct scrub_ctx *scrub_setup_ctx(struc
        struct btrfs_fs_info *fs_info = dev->dev_root->fs_info;
        int ret;
  
-       sctx = kzalloc(sizeof(*sctx), GFP_NOFS);
+       sctx = kzalloc(sizeof(*sctx), GFP_KERNEL);
        if (!sctx)
                goto nomem;
        atomic_set(&sctx->refs, 1);
        for (i = 0; i < SCRUB_BIOS_PER_SCTX; ++i) {
                struct scrub_bio *sbio;
  
-               sbio = kzalloc(sizeof(*sbio), GFP_NOFS);
+               sbio = kzalloc(sizeof(*sbio), GFP_KERNEL);
                if (!sbio)
                        goto nomem;
                sctx->bios[i] = sbio;
@@@ -1514,6 -1514,8 +1514,6 @@@ static void scrub_recheck_block(struct 
  
        if (sblock->no_io_error_seen)
                scrub_recheck_block_checksum(sblock);
 -
 -      return;
  }
  
  static inline int scrub_check_fsid(u8 fsid[],
@@@ -1654,7 -1656,7 +1654,7 @@@ static int scrub_add_page_to_wr_bio(str
  again:
        if (!wr_ctx->wr_curr_bio) {
                wr_ctx->wr_curr_bio = kzalloc(sizeof(*wr_ctx->wr_curr_bio),
-                                             GFP_NOFS);
+                                             GFP_KERNEL);
                if (!wr_ctx->wr_curr_bio) {
                        mutex_unlock(&wr_ctx->wr_lock);
                        return -ENOMEM;
                sbio->dev = wr_ctx->tgtdev;
                bio = sbio->bio;
                if (!bio) {
-                       bio = btrfs_io_bio_alloc(GFP_NOFS, wr_ctx->pages_per_wr_bio);
+                       bio = btrfs_io_bio_alloc(GFP_KERNEL,
+                                       wr_ctx->pages_per_wr_bio);
                        if (!bio) {
                                mutex_unlock(&wr_ctx->wr_lock);
                                return -ENOMEM;
@@@ -2076,7 -2079,8 +2077,8 @@@ again
                sbio->dev = spage->dev;
                bio = sbio->bio;
                if (!bio) {
-                       bio = btrfs_io_bio_alloc(GFP_NOFS, sctx->pages_per_rd_bio);
+                       bio = btrfs_io_bio_alloc(GFP_KERNEL,
+                                       sctx->pages_per_rd_bio);
                        if (!bio)
                                return -ENOMEM;
                        sbio->bio = bio;
@@@ -2241,7 -2245,7 +2243,7 @@@ static int scrub_pages(struct scrub_ct
        struct scrub_block *sblock;
        int index;
  
-       sblock = kzalloc(sizeof(*sblock), GFP_NOFS);
+       sblock = kzalloc(sizeof(*sblock), GFP_KERNEL);
        if (!sblock) {
                spin_lock(&sctx->stat_lock);
                sctx->stat.malloc_errors++;
                struct scrub_page *spage;
                u64 l = min_t(u64, len, PAGE_SIZE);
  
-               spage = kzalloc(sizeof(*spage), GFP_NOFS);
+               spage = kzalloc(sizeof(*spage), GFP_KERNEL);
                if (!spage) {
  leave_nomem:
                        spin_lock(&sctx->stat_lock);
                        spage->have_csum = 0;
                }
                sblock->page_count++;
-               spage->page = alloc_page(GFP_NOFS);
+               spage->page = alloc_page(GFP_KERNEL);
                if (!spage->page)
                        goto leave_nomem;
                len -= l;
@@@ -2541,7 -2545,7 +2543,7 @@@ static int scrub_pages_for_parity(struc
        struct scrub_block *sblock;
        int index;
  
-       sblock = kzalloc(sizeof(*sblock), GFP_NOFS);
+       sblock = kzalloc(sizeof(*sblock), GFP_KERNEL);
        if (!sblock) {
                spin_lock(&sctx->stat_lock);
                sctx->stat.malloc_errors++;
                struct scrub_page *spage;
                u64 l = min_t(u64, len, PAGE_SIZE);
  
-               spage = kzalloc(sizeof(*spage), GFP_NOFS);
+               spage = kzalloc(sizeof(*spage), GFP_KERNEL);
                if (!spage) {
  leave_nomem:
                        spin_lock(&sctx->stat_lock);
                        spage->have_csum = 0;
                }
                sblock->page_count++;
-               spage->page = alloc_page(GFP_NOFS);
+               spage->page = alloc_page(GFP_KERNEL);
                if (!spage->page)
                        goto leave_nomem;
                len -= l;
@@@ -2813,7 -2817,7 +2815,7 @@@ out
  
  static inline int scrub_calc_parity_bitmap_len(int nsectors)
  {
 -      return DIV_ROUND_UP(nsectors, BITS_PER_LONG) * (BITS_PER_LONG / 8);
 +      return DIV_ROUND_UP(nsectors, BITS_PER_LONG) * sizeof(long);
  }
  
  static void scrub_parity_get(struct scrub_parity *sparity)
@@@ -3430,9 -3434,7 +3432,9 @@@ out
  static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
                                          struct btrfs_device *scrub_dev,
                                          u64 chunk_offset, u64 length,
 -                                        u64 dev_offset, int is_dev_replace)
 +                                        u64 dev_offset,
 +                                        struct btrfs_block_group_cache *cache,
 +                                        int is_dev_replace)
  {
        struct btrfs_mapping_tree *map_tree =
                &sctx->dev_root->fs_info->mapping_tree;
        em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1);
        read_unlock(&map_tree->map_tree.lock);
  
 -      if (!em)
 -              return -EINVAL;
 +      if (!em) {
 +              /*
 +               * Might have been an unused block group deleted by the cleaner
 +               * kthread or relocation.
 +               */
 +              spin_lock(&cache->lock);
 +              if (!cache->removed)
 +                      ret = -EINVAL;
 +              spin_unlock(&cache->lock);
  
 -      map = (struct map_lookup *)em->bdev;
 +              return ret;
 +      }
 +
 +      map = em->map_lookup;
        if (em->start != chunk_offset)
                goto out;
  
@@@ -3493,7 -3485,6 +3495,7 @@@ int scrub_enumerate_chunks(struct scrub
        u64 length;
        u64 chunk_offset;
        int ret = 0;
 +      int ro_set;
        int slot;
        struct extent_buffer *l;
        struct btrfs_key key;
        if (!path)
                return -ENOMEM;
  
 -      path->reada = 2;
 +      path->reada = READA_FORWARD;
        path->search_commit_root = 1;
        path->skip_locking = 1;
  
                scrub_pause_on(fs_info);
                ret = btrfs_inc_block_group_ro(root, cache);
                scrub_pause_off(fs_info);
 -              if (ret) {
 +
 +              if (ret == 0) {
 +                      ro_set = 1;
 +              } else if (ret == -ENOSPC) {
 +                      /*
 +                       * btrfs_inc_block_group_ro return -ENOSPC when it
 +                       * failed in creating new chunk for metadata.
 +                       * It is not a problem for scrub/replace, because
 +                       * metadata are always cowed, and our scrub paused
 +                       * commit_transactions.
 +                       */
 +                      ro_set = 0;
 +              } else {
 +                      btrfs_warn(fs_info, "failed setting block group ro, ret=%d\n",
 +                                 ret);
                        btrfs_put_block_group(cache);
                        break;
                }
                dev_replace->cursor_left = found_key.offset;
                dev_replace->item_needs_writeback = 1;
                ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length,
 -                                found_key.offset, is_dev_replace);
 +                                found_key.offset, cache, is_dev_replace);
  
                /*
                 * flush, submit all pending read and write bios, afterwards
  
                scrub_pause_off(fs_info);
  
 -              btrfs_dec_block_group_ro(root, cache);
 +              if (ro_set)
 +                      btrfs_dec_block_group_ro(root, cache);
 +
 +              /*
 +               * We might have prevented the cleaner kthread from deleting
 +               * this block group if it was already unused because we raced
 +               * and set it to RO mode first. So add it back to the unused
 +               * list, otherwise it might not ever be deleted unless a manual
 +               * balance is triggered or it becomes used and unused again.
 +               */
 +              spin_lock(&cache->lock);
 +              if (!cache->removed && !cache->ro && cache->reserved == 0 &&
 +                  btrfs_block_group_used(&cache->item) == 0) {
 +                      spin_unlock(&cache->lock);
 +                      spin_lock(&fs_info->unused_bgs_lock);
 +                      if (list_empty(&cache->bg_list)) {
 +                              btrfs_get_block_group(cache);
 +                              list_add_tail(&cache->bg_list,
 +                                            &fs_info->unused_bgs);
 +                      }
 +                      spin_unlock(&fs_info->unused_bgs_lock);
 +              } else {
 +                      spin_unlock(&cache->lock);
 +              }
  
                btrfs_put_block_group(cache);
                if (ret)
@@@ -3733,27 -3687,27 +3735,27 @@@ static noinline_for_stack int scrub_wor
        if (fs_info->scrub_workers_refcnt == 0) {
                if (is_dev_replace)
                        fs_info->scrub_workers =
 -                              btrfs_alloc_workqueue("btrfs-scrub", flags,
 +                              btrfs_alloc_workqueue("scrub", flags,
                                                      1, 4);
                else
                        fs_info->scrub_workers =
 -                              btrfs_alloc_workqueue("btrfs-scrub", flags,
 +                              btrfs_alloc_workqueue("scrub", flags,
                                                      max_active, 4);
                if (!fs_info->scrub_workers)
                        goto fail_scrub_workers;
  
                fs_info->scrub_wr_completion_workers =
 -                      btrfs_alloc_workqueue("btrfs-scrubwrc", flags,
 +                      btrfs_alloc_workqueue("scrubwrc", flags,
                                              max_active, 2);
                if (!fs_info->scrub_wr_completion_workers)
                        goto fail_scrub_wr_completion_workers;
  
                fs_info->scrub_nocow_workers =
 -                      btrfs_alloc_workqueue("btrfs-scrubnc", flags, 1, 0);
 +                      btrfs_alloc_workqueue("scrubnc", flags, 1, 0);
                if (!fs_info->scrub_nocow_workers)
                        goto fail_scrub_nocow_workers;
                fs_info->scrub_parity_workers =
 -                      btrfs_alloc_workqueue("btrfs-scrubparity", flags,
 +                      btrfs_alloc_workqueue("scrubparity", flags,
                                              max_active, 2);
                if (!fs_info->scrub_parity_workers)
                        goto fail_scrub_parity_workers;
@@@ -4209,7 -4163,7 +4211,7 @@@ static int check_extent_to_block(struc
  
        io_tree = &BTRFS_I(inode)->io_tree;
  
 -      lock_extent_bits(io_tree, lockstart, lockend, 0, &cached_state);
 +      lock_extent_bits(io_tree, lockstart, lockend, &cached_state);
        ordered = btrfs_lookup_ordered_range(inode, lockstart, len);
        if (ordered) {
                btrfs_put_ordered_extent(ordered);
diff --combined fs/btrfs/send.c
index 63a6152be04b4f4265b25e253eadb1d4d91b8969,1affded5fba07b66f28d8c548136625947cba47d..d2e29925f1da3bc6f3d4ce3846733cd058a301bf
@@@ -304,7 -304,7 +304,7 @@@ static struct fs_path *fs_path_alloc(vo
  {
        struct fs_path *p;
  
-       p = kmalloc(sizeof(*p), GFP_NOFS);
+       p = kmalloc(sizeof(*p), GFP_KERNEL);
        if (!p)
                return NULL;
        p->reversed = 0;
@@@ -363,11 -363,11 +363,11 @@@ static int fs_path_ensure_buf(struct fs
         * First time the inline_buf does not suffice
         */
        if (p->buf == p->inline_buf) {
-               tmp_buf = kmalloc(len, GFP_NOFS);
+               tmp_buf = kmalloc(len, GFP_KERNEL);
                if (tmp_buf)
                        memcpy(tmp_buf, p->buf, old_buf_len);
        } else {
-               tmp_buf = krealloc(p->buf, len, GFP_NOFS);
+               tmp_buf = krealloc(p->buf, len, GFP_KERNEL);
        }
        if (!tmp_buf)
                return -ENOMEM;
@@@ -995,7 -995,7 +995,7 @@@ static int iterate_dir_item(struct btrf
         * values are small.
         */
        buf_len = PATH_MAX;
-       buf = kmalloc(buf_len, GFP_NOFS);
+       buf = kmalloc(buf_len, GFP_KERNEL);
        if (!buf) {
                ret = -ENOMEM;
                goto out;
                                buf = NULL;
                        } else {
                                char *tmp = krealloc(buf, buf_len,
-                                                    GFP_NOFS | __GFP_NOWARN);
+                                               GFP_KERNEL | __GFP_NOWARN);
  
                                if (!tmp)
                                        kfree(buf);
@@@ -1303,7 -1303,7 +1303,7 @@@ static int find_extent_clone(struct sen
        /* We only use this path under the commit sem */
        tmp_path->need_commit_sem = 0;
  
-       backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_NOFS);
+       backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_KERNEL);
        if (!backref_ctx) {
                ret = -ENOMEM;
                goto out;
@@@ -1469,21 -1469,7 +1469,21 @@@ static int read_symlink(struct btrfs_ro
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
                goto out;
 -      BUG_ON(ret);
 +      if (ret) {
 +              /*
 +               * An empty symlink inode. Can happen in rare error paths when
 +               * creating a symlink (transaction committed before the inode
 +               * eviction handler removed the symlink inode items and a crash
 +               * happened in between or the subvol was snapshoted in between).
 +               * Print an informative message to dmesg/syslog so that the user
 +               * can delete the symlink.
 +               */
 +              btrfs_err(root->fs_info,
 +                        "Found empty symlink inode %llu at root %llu",
 +                        ino, root->root_key.objectid);
 +              ret = -EIO;
 +              goto out;
 +      }
  
        ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
                        struct btrfs_file_extent_item);
@@@ -1984,7 -1970,7 +1984,7 @@@ static int name_cache_insert(struct sen
        nce_head = radix_tree_lookup(&sctx->name_cache,
                        (unsigned long)nce->ino);
        if (!nce_head) {
-               nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS);
+               nce_head = kmalloc(sizeof(*nce_head), GFP_KERNEL);
                if (!nce_head) {
                        kfree(nce);
                        return -ENOMEM;
@@@ -2179,7 -2165,7 +2179,7 @@@ out_cache
        /*
         * Store the result of the lookup in the name cache.
         */
-       nce = kmalloc(sizeof(*nce) + fs_path_len(dest) + 1, GFP_NOFS);
+       nce = kmalloc(sizeof(*nce) + fs_path_len(dest) + 1, GFP_KERNEL);
        if (!nce) {
                ret = -ENOMEM;
                goto out;
@@@ -2315,7 -2301,7 +2315,7 @@@ static int send_subvol_begin(struct sen
        if (!path)
                return -ENOMEM;
  
-       name = kmalloc(BTRFS_PATH_NAME_MAX, GFP_NOFS);
+       name = kmalloc(BTRFS_PATH_NAME_MAX, GFP_KERNEL);
        if (!name) {
                btrfs_free_path(path);
                return -ENOMEM;
@@@ -2730,7 -2716,7 +2730,7 @@@ static int __record_ref(struct list_hea
  {
        struct recorded_ref *ref;
  
-       ref = kmalloc(sizeof(*ref), GFP_NOFS);
+       ref = kmalloc(sizeof(*ref), GFP_KERNEL);
        if (!ref)
                return -ENOMEM;
  
@@@ -2755,7 -2741,7 +2755,7 @@@ static int dup_ref(struct recorded_ref 
  {
        struct recorded_ref *new;
  
-       new = kmalloc(sizeof(*ref), GFP_NOFS);
+       new = kmalloc(sizeof(*ref), GFP_KERNEL);
        if (!new)
                return -ENOMEM;
  
@@@ -2818,7 -2804,7 +2818,7 @@@ add_orphan_dir_info(struct send_ctx *sc
        struct rb_node *parent = NULL;
        struct orphan_dir_info *entry, *odi;
  
-       odi = kmalloc(sizeof(*odi), GFP_NOFS);
+       odi = kmalloc(sizeof(*odi), GFP_KERNEL);
        if (!odi)
                return ERR_PTR(-ENOMEM);
        odi->ino = dir_ino;
@@@ -2973,7 -2959,7 +2973,7 @@@ static int add_waiting_dir_move(struct 
        struct rb_node *parent = NULL;
        struct waiting_dir_move *entry, *dm;
  
-       dm = kmalloc(sizeof(*dm), GFP_NOFS);
+       dm = kmalloc(sizeof(*dm), GFP_KERNEL);
        if (!dm)
                return -ENOMEM;
        dm->ino = ino;
@@@ -3040,7 -3026,7 +3040,7 @@@ static int add_pending_dir_move(struct 
        int exists = 0;
        int ret;
  
-       pm = kmalloc(sizeof(*pm), GFP_NOFS);
+       pm = kmalloc(sizeof(*pm), GFP_KERNEL);
        if (!pm)
                return -ENOMEM;
        pm->parent_ino = parent_ino;
@@@ -4280,7 -4266,7 +4280,7 @@@ static int __find_xattr(int num, struc
            strncmp(name, ctx->name, name_len) == 0) {
                ctx->found_idx = num;
                ctx->found_data_len = data_len;
-               ctx->found_data = kmemdup(data, data_len, GFP_NOFS);
+               ctx->found_data = kmemdup(data, data_len, GFP_KERNEL);
                if (!ctx->found_data)
                        return -ENOMEM;
                return 1;
@@@ -4481,7 -4467,7 +4481,7 @@@ static ssize_t fill_read_buf(struct sen
        while (index <= last_index) {
                unsigned cur_len = min_t(unsigned, len,
                                         PAGE_CACHE_SIZE - pg_offset);
-               page = find_or_create_page(inode->i_mapping, index, GFP_NOFS);
+               page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
                if (!page) {
                        ret = -ENOMEM;
                        break;
@@@ -5989,7 -5975,7 +5989,7 @@@ long btrfs_ioctl_send(struct file *mnt_
                goto out;
        }
  
-       sctx = kzalloc(sizeof(struct send_ctx), GFP_NOFS);
+       sctx = kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
        if (!sctx) {
                ret = -ENOMEM;
                goto out;
  
        INIT_LIST_HEAD(&sctx->new_refs);
        INIT_LIST_HEAD(&sctx->deleted_refs);
-       INIT_RADIX_TREE(&sctx->name_cache, GFP_NOFS);
+       INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL);
        INIT_LIST_HEAD(&sctx->name_cache_list);
  
        sctx->flags = arg->flags;