super.c (ea3dc7d2d1f524eb2a34b6501be38c82be5c7ff1) super.c (0ff40a910f5649dfacc4fb5daa7e73692196342d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/module.h>
8#include <linux/fs.h>

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

1196 * Walk up the subvolume trees in the tree of tree roots by root
1197 * backrefs until we hit the top-level subvolume.
1198 */
1199 while (subvol_objectid != BTRFS_FS_TREE_OBJECTID) {
1200 key.objectid = subvol_objectid;
1201 key.type = BTRFS_ROOT_BACKREF_KEY;
1202 key.offset = (u64)-1;
1203
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/module.h>
8#include <linux/fs.h>

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

1196 * Walk up the subvolume trees in the tree of tree roots by root
1197 * backrefs until we hit the top-level subvolume.
1198 */
1199 while (subvol_objectid != BTRFS_FS_TREE_OBJECTID) {
1200 key.objectid = subvol_objectid;
1201 key.type = BTRFS_ROOT_BACKREF_KEY;
1202 key.offset = (u64)-1;
1203
1204 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1204 ret = btrfs_search_backwards(root, &key, path);
1205 if (ret < 0) {
1206 goto err;
1207 } else if (ret > 0) {
1205 if (ret < 0) {
1206 goto err;
1207 } else if (ret > 0) {
1208 ret = btrfs_previous_item(root, path, subvol_objectid,
1209 BTRFS_ROOT_BACKREF_KEY);
1210 if (ret < 0) {
1211 goto err;
1212 } else if (ret > 0) {
1213 ret = -ENOENT;
1214 goto err;
1215 }
1208 ret = -ENOENT;
1209 goto err;
1216 }
1217
1210 }
1211
1218 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
1219 subvol_objectid = key.offset;
1220
1221 root_ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1222 struct btrfs_root_ref);
1223 len = btrfs_root_ref_name_len(path->nodes[0], root_ref);
1224 ptr -= len + 1;
1225 if (ptr < name) {
1226 ret = -ENAMETOOLONG;

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

1243 * Walk up the filesystem tree by inode refs until we hit the
1244 * root directory.
1245 */
1246 while (dirid != BTRFS_FIRST_FREE_OBJECTID) {
1247 key.objectid = dirid;
1248 key.type = BTRFS_INODE_REF_KEY;
1249 key.offset = (u64)-1;
1250
1212 subvol_objectid = key.offset;
1213
1214 root_ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1215 struct btrfs_root_ref);
1216 len = btrfs_root_ref_name_len(path->nodes[0], root_ref);
1217 ptr -= len + 1;
1218 if (ptr < name) {
1219 ret = -ENAMETOOLONG;

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

1236 * Walk up the filesystem tree by inode refs until we hit the
1237 * root directory.
1238 */
1239 while (dirid != BTRFS_FIRST_FREE_OBJECTID) {
1240 key.objectid = dirid;
1241 key.type = BTRFS_INODE_REF_KEY;
1242 key.offset = (u64)-1;
1243
1251 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0);
1244 ret = btrfs_search_backwards(fs_root, &key, path);
1252 if (ret < 0) {
1253 goto err;
1254 } else if (ret > 0) {
1245 if (ret < 0) {
1246 goto err;
1247 } else if (ret > 0) {
1255 ret = btrfs_previous_item(fs_root, path, dirid,
1256 BTRFS_INODE_REF_KEY);
1257 if (ret < 0) {
1258 goto err;
1259 } else if (ret > 0) {
1260 ret = -ENOENT;
1261 goto err;
1262 }
1248 ret = -ENOENT;
1249 goto err;
1263 }
1264
1250 }
1251
1265 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
1266 dirid = key.offset;
1267
1268 inode_ref = btrfs_item_ptr(path->nodes[0],
1269 path->slots[0],
1270 struct btrfs_inode_ref);
1271 len = btrfs_inode_ref_name_len(path->nodes[0],
1272 inode_ref);
1273 ptr -= len + 1;

--- 1429 unchanged lines hidden ---
1252 dirid = key.offset;
1253
1254 inode_ref = btrfs_item_ptr(path->nodes[0],
1255 path->slots[0],
1256 struct btrfs_inode_ref);
1257 len = btrfs_inode_ref_name_len(path->nodes[0],
1258 inode_ref);
1259 ptr -= len + 1;

--- 1429 unchanged lines hidden ---