~ubuntu-branches/debian/stretch/btrfs-tools/stretch

« back to all changes in this revision

Viewing changes to random-test.c

  • Committer: Package Import Robot
  • Author(s): Dimitri John Ledkov, Julien Muchembled, Dimitri John Ledkov
  • Date: 2014-01-01 01:52:43 UTC
  • mfrom: (1.2.11) (6.1.36 sid)
  • Revision ID: package-import@ubuntu.com-20140101015243-ieibqu475r4otkhz
Tags: 3.12-1
[ Julien Muchembled ]
* New upstream release. (Closes: #732075, #732533)
* Drop patches merged upstream:
  - 07-manpage2.patch
  - 10-soname.patch
  - Btrfs-progs-fix-wrong-arg-sb_bytenr-for-btrfs_scan_fs_devices.patch
* Refresh patches. (Closes: #719072)

[ Dimitri John Ledkov ]
* Add watch file.
* Bump standards version to 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        ret = radix_tree_gang_lookup(root, (void **)res, num, 2);
44
44
        if (exists) {
45
45
                if (ret == 0)
46
 
                        return -1;
 
46
                        return -EEXIST;
47
47
                num = res[0];
48
48
        } else if (ret != 0 && num == res[0]) {
49
49
                num++;
79
79
        return ret;
80
80
error:
81
81
        printf("failed to insert %llu\n", (unsigned long long)key.objectid);
82
 
        return -1;
 
82
        return ret;
83
83
}
84
84
 
85
85
static int insert_dup(struct btrfs_trans_handle *trans, struct btrfs_root
98
98
        if (ret != -EEXIST) {
99
99
                printf("insert on %llu gave us %d\n",
100
100
                       (unsigned long long)key.objectid, ret);
101
 
                return 1;
 
101
                return ret;
102
102
        }
103
103
        return 0;
104
104
}
118
118
        if (ret)
119
119
                goto error;
120
120
        ret = btrfs_del_item(trans, root, &path);
121
 
        btrfs_release_path(root, &path);
 
121
        btrfs_release_path(&path);
122
122
        if (ret != 0)
123
123
                goto error;
124
124
        ptr = radix_tree_delete(radix, key.objectid);
127
127
        return 0;
128
128
error:
129
129
        printf("failed to delete %llu\n", (unsigned long long)key.objectid);
130
 
        return -1;
 
130
        return ret;
131
131
}
132
132
 
133
133
static int lookup_item(struct btrfs_trans_handle *trans, struct btrfs_root
141
141
        if (ret < 0)
142
142
                return 0;
143
143
        ret = btrfs_search_slot(trans, root, &key, &path, 0, 1);
144
 
        btrfs_release_path(root, &path);
 
144
        btrfs_release_path(&path);
145
145
        if (ret)
146
146
                goto error;
147
147
        return 0;
148
148
error:
149
149
        printf("unable to find key %llu\n", (unsigned long long)key.objectid);
150
 
        return -1;
 
150
        return ret;
151
151
}
152
152
 
153
153
static int lookup_enoent(struct btrfs_trans_handle *trans, struct btrfs_root
161
161
        if (ret < 0)
162
162
                return ret;
163
163
        ret = btrfs_search_slot(trans, root, &key, &path, 0, 0);
164
 
        btrfs_release_path(root, &path);
 
164
        btrfs_release_path(&path);
165
165
        if (ret <= 0)
166
166
                goto error;
167
167
        return 0;
168
168
error:
169
169
        printf("able to find key that should not exist %llu\n",
170
170
               (unsigned long long)key.objectid);
171
 
        return -1;
 
171
        return -EEXIST;
172
172
}
173
173
 
174
174
static int empty_tree(struct btrfs_trans_handle *trans, struct btrfs_root
190
190
                btrfs_init_path(&path);
191
191
                ret = btrfs_search_slot(trans, root, &key, &path, -1, 1);
192
192
                if (ret < 0) {
193
 
                        btrfs_release_path(root, &path);
 
193
                        btrfs_release_path(&path);
194
194
                        return ret;
195
195
                }
196
196
                if (ret != 0) {
197
197
                        if (path.slots[0] == 0) {
198
 
                                btrfs_release_path(root, &path);
 
198
                                btrfs_release_path(&path);
199
199
                                break;
200
200
                        }
201
201
                        path.slots[0] -= 1;
209
209
                        fprintf(stderr,
210
210
                                "failed to remove %lu from tree\n",
211
211
                                found);
212
 
                        return -1;
 
212
                        return ret;
213
213
                }
214
 
                btrfs_release_path(root, &path);
 
214
                btrfs_release_path(&path);
215
215
                ptr = radix_tree_delete(radix, found);
216
216
                if (!ptr)
217
217
                        goto error;
221
221
        return 0;
222
222
error:
223
223
        fprintf(stderr, "failed to delete from the radix %lu\n", found);
224
 
        return -1;
 
224
        return -ENOENT;
225
225
}
226
226
 
227
227
static int fill_tree(struct btrfs_trans_handle *trans, struct btrfs_root *root,
294
294
                btrfs_init_path(&path);
295
295
                ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
296
296
                if (ret < 0) {
297
 
                        btrfs_release_path(root, &path);
 
297
                        btrfs_release_path(&path);
298
298
                        return ret;
299
299
                }
300
300
                slot = path.slots[0];
301
301
                if (ret != 0) {
302
302
                        if (slot == 0) {
303
 
                                btrfs_release_path(root, &path);
 
303
                                btrfs_release_path(&path);
304
304
                                break;
305
305
                        }
306
306
                        slot -= 1;
319
319
 
320
320
                        radix_tree_preload_end();
321
321
                }
322
 
                btrfs_release_path(root, &path);
 
322
                btrfs_release_path(&path);
323
323
                key.objectid = found - 1;
324
324
                if (key.objectid > found)
325
325
                        break;
428
428
        }
429
429
out:
430
430
        close_ctree(root, &super);
431
 
        return err;
 
431
        return !!err;
432
432
}
433
433