ioctl.c (4922f0920966c28d674b03479cdcb7f3939bfbbd) ioctl.c (7a1636089acfee7562fe79aff7d1b4c57869896d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/kernel.h>
7#include <linux/bio.h>
8#include <linux/file.h>

--- 603 unchanged lines hidden (view full) ---

612 key.type = BTRFS_ROOT_ITEM_KEY;
613 ret = btrfs_insert_root(trans, fs_info->tree_root, &key,
614 root_item);
615 if (ret) {
616 /*
617 * Since we don't abort the transaction in this case, free the
618 * tree block so that we don't leak space and leave the
619 * filesystem in an inconsistent state (an extent item in the
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/kernel.h>
7#include <linux/bio.h>
8#include <linux/file.h>

--- 603 unchanged lines hidden (view full) ---

612 key.type = BTRFS_ROOT_ITEM_KEY;
613 ret = btrfs_insert_root(trans, fs_info->tree_root, &key,
614 root_item);
615 if (ret) {
616 /*
617 * Since we don't abort the transaction in this case, free the
618 * tree block so that we don't leak space and leave the
619 * filesystem in an inconsistent state (an extent item in the
620 * extent tree without backreferences). Also no need to have
621 * the tree block locked since it is not in any tree at this
622 * point, so no other task can find it and use it.
620 * extent tree with a backreference for a root that does not
621 * exists). Also no need to have the tree block locked since it
622 * is not in any tree at this point, so no other task can find
623 * it and use it.
623 */
624 */
624 btrfs_free_tree_block(trans, root, leaf, 0, 1);
625 btrfs_free_tree_block(trans, objectid, leaf, 0, 1);
625 free_extent_buffer(leaf);
626 goto fail;
627 }
628
629 free_extent_buffer(leaf);
630 leaf = NULL;
631
632 key.offset = (u64)-1;

--- 1053 unchanged lines hidden (view full) ---

1686 btrfs_info(fs_info,
1687 "resizer unable to apply on readonly device %llu",
1688 devid);
1689 ret = -EPERM;
1690 goto out_finish;
1691 }
1692
1693 if (!strcmp(sizestr, "max"))
626 free_extent_buffer(leaf);
627 goto fail;
628 }
629
630 free_extent_buffer(leaf);
631 leaf = NULL;
632
633 key.offset = (u64)-1;

--- 1053 unchanged lines hidden (view full) ---

1687 btrfs_info(fs_info,
1688 "resizer unable to apply on readonly device %llu",
1689 devid);
1690 ret = -EPERM;
1691 goto out_finish;
1692 }
1693
1694 if (!strcmp(sizestr, "max"))
1694 new_size = bdev_nr_bytes(device->bdev);
1695 new_size = device->bdev->bd_inode->i_size;
1695 else {
1696 if (sizestr[0] == '-') {
1697 mod = -1;
1698 sizestr++;
1699 } else if (sizestr[0] == '+') {
1700 mod = 1;
1701 sizestr++;
1702 }

--- 24 unchanged lines hidden (view full) ---

1727 }
1728 new_size = old_size + new_size;
1729 }
1730
1731 if (new_size < SZ_256M) {
1732 ret = -EINVAL;
1733 goto out_finish;
1734 }
1696 else {
1697 if (sizestr[0] == '-') {
1698 mod = -1;
1699 sizestr++;
1700 } else if (sizestr[0] == '+') {
1701 mod = 1;
1702 sizestr++;
1703 }

--- 24 unchanged lines hidden (view full) ---

1728 }
1729 new_size = old_size + new_size;
1730 }
1731
1732 if (new_size < SZ_256M) {
1733 ret = -EINVAL;
1734 goto out_finish;
1735 }
1735 if (new_size > bdev_nr_bytes(device->bdev)) {
1736 if (new_size > device->bdev->bd_inode->i_size) {
1736 ret = -EFBIG;
1737 goto out_finish;
1738 }
1739
1740 new_size = round_down(new_size, fs_info->sectorsize);
1741
1742 if (new_size > old_size) {
1743 trans = btrfs_start_transaction(root, 0);

--- 473 unchanged lines hidden (view full) ---

2217 }
2218 }
2219
2220 key.objectid = sk->min_objectid;
2221 key.type = sk->min_type;
2222 key.offset = sk->min_offset;
2223
2224 while (1) {
1737 ret = -EFBIG;
1738 goto out_finish;
1739 }
1740
1741 new_size = round_down(new_size, fs_info->sectorsize);
1742
1743 if (new_size > old_size) {
1744 trans = btrfs_start_transaction(root, 0);

--- 473 unchanged lines hidden (view full) ---

2218 }
2219 }
2220
2221 key.objectid = sk->min_objectid;
2222 key.type = sk->min_type;
2223 key.offset = sk->min_offset;
2224
2225 while (1) {
2225 ret = -EFAULT;
2226 if (fault_in_writeable(ubuf + sk_offset, *buf_size - sk_offset))
2226 ret = fault_in_pages_writeable(ubuf + sk_offset,
2227 *buf_size - sk_offset);
2228 if (ret)
2227 break;
2228
2229 ret = btrfs_search_forward(root, &key, path, sk->min_transid);
2230 if (ret != 0) {
2231 if (ret > 0)
2232 ret = 0;
2233 goto err;
2234 }

--- 2794 unchanged lines hidden ---
2229 break;
2230
2231 ret = btrfs_search_forward(root, &key, path, sk->min_transid);
2232 if (ret != 0) {
2233 if (ret > 0)
2234 ret = 0;
2235 goto err;
2236 }

--- 2794 unchanged lines hidden ---