Commit f959492
Btrfs: send, fix more issues related to directory renames
This is a continuation of the previous changes titled:
Btrfs: fix incremental send's decision to delay a dir move/rename
Btrfs: part 2, fix incremental send's decision to delay a dir move/rename
There's a few more cases where a directory rename/move must be delayed which was
previously overlooked. If our immediate ancestor has a lower inode number than
ours and it doesn't have a delayed rename/move operation associated to it, it
doesn't mean there isn't any non-direct ancestor of our current inode that needs
to be renamed/moved before our current inode (i.e. with a higher inode number
than ours).
So we can't stop the search if our immediate ancestor has a lower inode number than
ours, we need to navigate the directory hierarchy upwards until we hit the root or:
1) find an ancestor with an higher inode number that was renamed/moved in the send
root too (or already has a pending rename/move registered);
2) find an ancestor that is a new directory (higher inode number than ours and
exists only in the send root).
Reproducer for case 1)
$ mkfs.btrfs -f /dev/sdd
$ mount /dev/sdd /mnt
$ mkdir -p /mnt/a/b
$ mkdir -p /mnt/a/c/d
$ mkdir /mnt/a/b/e
$ mkdir /mnt/a/c/d/f
$ mv /mnt/a/b /mnt/a/c/d/2b
$ mkdir /mnt/a/x
$ mkdir /mnt/a/y
$ btrfs subvolume snapshot -r /mnt /mnt/snap1
$ btrfs send /mnt/snap1 -f /tmp/base.send
$ mv /mnt/a/x /mnt/a/y
$ mv /mnt/a/c/d/2b/e /mnt/a/c/d/2b/2e
$ mv /mnt/a/c/d /mnt/a/h/2d
$ mv /mnt/a/c /mnt/a/h/2d/2b/2c
$ btrfs subvolume snapshot -r /mnt /mnt/snap2
$ btrfs send -p /mnt/snap1 /mnt/snap2 -f /tmp/incremental.send
Simple reproducer for case 2)
$ mkfs.btrfs -f /dev/sdd
$ mount /dev/sdd /mnt
$ mkdir -p /mnt/a/b
$ mkdir /mnt/a/c
$ mv /mnt/a/b /mnt/a/c/b2
$ mkdir /mnt/a/e
$ btrfs subvolume snapshot -r /mnt /mnt/snap1
$ btrfs send /mnt/snap1 -f /tmp/base.send
$ mv /mnt/a/c/b2 /mnt/a/e/b3
$ mkdir /mnt/a/e/b3/f
$ mkdir /mnt/a/h
$ mv /mnt/a/c /mnt/a/e/b3/f/c2
$ mv /mnt/a/e /mnt/a/h/e2
$ btrfs subvolume snapshot -r /mnt /mnt/snap2
$ btrfs send -p /mnt/snap1 /mnt/snap2 -f /tmp/incremental.send
Another simple reproducer for case 2)
$ mkfs.btrfs -f /dev/sdd
$ mount /dev/sdd /mnt
$ mkdir -p /mnt/a/b
$ mkdir /mnt/a/c
$ mkdir /mnt/a/b/d
$ mkdir /mnt/a/c/e
$ btrfs subvolume snapshot -r /mnt /mnt/snap1
$ btrfs send /mnt/snap1 -f /tmp/base.send
$ mkdir /mnt/a/b/d/f
$ mkdir /mnt/a/b/g
$ mv /mnt/a/c/e /mnt/a/b/g/e2
$ mv /mnt/a/c /mnt/a/b/d/f/c2
$ mv /mnt/a/b/d/f /mnt/a/b/g/e2/f2
$ btrfs subvolume snapshot -r /mnt /mnt/snap2
$ btrfs send -p /mnt/snap1 /mnt/snap2 -f /tmp/incremental.send
More complex reproducer for case 2)
$ mkfs.btrfs -f /dev/sdd
$ mount /dev/sdd /mnt
$ mkdir -p /mnt/a/b
$ mkdir -p /mnt/a/c/d
$ mkdir /mnt/a/b/e
$ mkdir /mnt/a/c/d/f
$ mv /mnt/a/b /mnt/a/c/d/2b
$ mkdir /mnt/a/x
$ mkdir /mnt/a/y
$ btrfs subvolume snapshot -r /mnt /mnt/snap1
$ btrfs send /mnt/snap1 -f /tmp/base.send
$ mv /mnt/a/x /mnt/a/y
$ mv /mnt/a/c/d/2b/e /mnt/a/c/d/2b/2e
$ mv /mnt/a/c/d /mnt/a/h/2d
$ mv /mnt/a/c /mnt/a/h/2d/2b/2c
$ btrfs subvolume snapshot -r /mnt /mnt/snap2
$ btrfs send -p /mnt/snap1 /mnt/snap2 -f /tmp/incremental.send
For both cases the incremental send would enter an infinite loop when building
path strings.
While solving these cases, this change also re-implements the code to detect
when directory moves/renames should be delayed. Instead of dealing with several
specific cases separately, it's now more generic handling all cases with a simple
detection algorithm and if when applying a delayed move/rename there's a path loop
detected, it further delays the move/rename registering a new ancestor inode as
the dependency inode (so our rename happens after that ancestor is renamed).
Tests for these cases is being added to xfstests too.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Chris Mason <clm@fb.com>1 parent a10c407 commit f959492
1 file changed
+96
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2940 | 2940 | | |
2941 | 2941 | | |
2942 | 2942 | | |
2943 | | - | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
2944 | 2946 | | |
2945 | 2947 | | |
2946 | 2948 | | |
| |||
2972 | 2974 | | |
2973 | 2975 | | |
2974 | 2976 | | |
2975 | | - | |
| 2977 | + | |
2976 | 2978 | | |
2977 | 2979 | | |
2978 | 2980 | | |
2979 | 2981 | | |
2980 | | - | |
| 2982 | + | |
2981 | 2983 | | |
2982 | 2984 | | |
2983 | 2985 | | |
| |||
3020 | 3022 | | |
3021 | 3023 | | |
3022 | 3024 | | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
3023 | 3067 | | |
3024 | 3068 | | |
3025 | 3069 | | |
| |||
3031 | 3075 | | |
3032 | 3076 | | |
3033 | 3077 | | |
| 3078 | + | |
3034 | 3079 | | |
3035 | 3080 | | |
3036 | 3081 | | |
| |||
3057 | 3102 | | |
3058 | 3103 | | |
3059 | 3104 | | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
3060 | 3121 | | |
3061 | 3122 | | |
3062 | 3123 | | |
3063 | | - | |
3064 | | - | |
3065 | 3124 | | |
3066 | 3125 | | |
3067 | 3126 | | |
| |||
3185 | 3244 | | |
3186 | 3245 | | |
3187 | 3246 | | |
3188 | | - | |
| 3247 | + | |
3189 | 3248 | | |
3190 | 3249 | | |
3191 | | - | |
3192 | 3250 | | |
3193 | 3251 | | |
3194 | 3252 | | |
3195 | | - | |
3196 | | - | |
3197 | | - | |
3198 | | - | |
3199 | | - | |
3200 | | - | |
3201 | | - | |
3202 | | - | |
3203 | | - | |
3204 | | - | |
3205 | | - | |
3206 | | - | |
3207 | | - | |
3208 | | - | |
3209 | | - | |
3210 | | - | |
3211 | | - | |
3212 | | - | |
3213 | | - | |
3214 | | - | |
3215 | | - | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
3219 | | - | |
3220 | | - | |
3221 | | - | |
3222 | | - | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
3226 | 3253 | | |
3227 | 3254 | | |
3228 | | - | |
| 3255 | + | |
| 3256 | + | |
3229 | 3257 | | |
3230 | 3258 | | |
3231 | 3259 | | |
3232 | 3260 | | |
3233 | | - | |
3234 | | - | |
3235 | | - | |
3236 | | - | |
3237 | | - | |
3238 | | - | |
3239 | | - | |
3240 | | - | |
3241 | | - | |
3242 | | - | |
3243 | | - | |
3244 | | - | |
3245 | | - | |
3246 | | - | |
3247 | | - | |
3248 | | - | |
3249 | | - | |
3250 | | - | |
3251 | 3261 | | |
3252 | | - | |
3253 | | - | |
3254 | | - | |
3255 | | - | |
3256 | | - | |
3257 | | - | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
3258 | 3266 | | |
3259 | | - | |
3260 | | - | |
3261 | | - | |
3262 | | - | |
3263 | | - | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
3264 | 3272 | | |
3265 | 3273 | | |
3266 | 3274 | | |
3267 | 3275 | | |
3268 | 3276 | | |
3269 | | - | |
| 3277 | + | |
3270 | 3278 | | |
3271 | 3279 | | |
3272 | 3280 | | |
3273 | 3281 | | |
3274 | | - | |
3275 | | - | |
3276 | | - | |
3277 | | - | |
| 3282 | + | |
3278 | 3283 | | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
3279 | 3287 | | |
3280 | 3288 | | |
3281 | 3289 | | |
3282 | 3290 | | |
3283 | | - | |
3284 | | - | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
3285 | 3294 | | |
3286 | | - | |
3287 | | - | |
3288 | | - | |
3289 | | - | |
3290 | | - | |
3291 | | - | |
3292 | | - | |
3293 | | - | |
3294 | | - | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
3298 | | - | |
| 3295 | + | |
3299 | 3296 | | |
3300 | | - | |
3301 | 3297 | | |
3302 | | - | |
3303 | 3298 | | |
3304 | 3299 | | |
3305 | 3300 | | |
3306 | 3301 | | |
3307 | 3302 | | |
3308 | 3303 | | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
3309 | 3315 | | |
3310 | 3316 | | |
3311 | 3317 | | |
| |||
3466 | 3472 | | |
3467 | 3473 | | |
3468 | 3474 | | |
3469 | | - | |
3470 | | - | |
3471 | | - | |
3472 | | - | |
3473 | 3475 | | |
3474 | 3476 | | |
3475 | 3477 | | |
| |||
0 commit comments