Refuse to revive an NBD device with another image #155
Open
koolkhel
wants to merge 1 commits from
koolkhel/vitastor:nbd-backend-identifier into master
pull from: koolkhel/vitastor:nbd-backend-identifier
merge into: vitalif:master
vitalif:master
vitalif:primary-stickiness
vitalif:libvfn
vitalif:canceling
vitalif:immediate-repeering
vitalif:rdma-close-tcp
vitalif:use-degraded-writes
vitalif:fix-write-delete-flow
vitalif:openssl-3.0.12
vitalif:openssl-capture-secrets
vitalif:ignore-small-rdma-end
vitalif:encrypt-batch
vitalif:faster-peering-calc
vitalif:http-hello
vitalif:xxh3-bench
vitalif:create-user-etcd-based
vitalif:aesxts_streaming_nosupport
vitalif:refactor-heap-continue-write
vitalif:ston3lu-patch-0127
vitalif:rdma-credits
vitalif:heap-meta
vitalif:sendmsg-zc-no-more-error
vitalif:fix-clear-refs
vitalif:veeam-trick
vitalif:test-etcd-schizo
vitalif:test
vitalif:test1
vitalif:test2
vitalif:cow-meta
vitalif:kv-readahead
vitalif:qemu-fix-crash-idea
vitalif:eventloop-auto-init-trigger
vitalif:hugo-docs
vitalif:node-mutex-and-postpone
vitalif:check-writeback
vitalif:msgr-iothreads-v2
vitalif:antietcd
vitalif:rel-1.4
vitalif:test-fix-ec-unknown-state-51
vitalif:kv-update
vitalif:kv-debug
vitalif:hotfix-1.2.0
vitalif:rdma-simple-nodp
vitalif:zerocopy-tcp-send
vitalif:csi-staging
vitalif:hotfix-1.1.0
vitalif:hotfix-1.0.0
vitalif:fsync-feedback
vitalif:cached-reads
vitalif:qemu-send-loop
vitalif:test-double-alloc
vitalif:hier-failure-domains
vitalif:mon-self-restart
vitalif:epoch-deletions
vitalif:rdma-flow-control
vitalif:csi-use-vitastor-cli
vitalif:rdma-v2
vitalif:etcd-hide-base64
vitalif:lrc-matrix
vitalif:rm-left-on-dead
vitalif:nfs-proxy-old
vitalif:non-odp-rdma
vitalif:test-zctr
vitalif:separate-data-connections
vitalif:sec_osd_msgr
vitalif:test-assert
vitalif:nbd-vmsplice
vitalif:allow-etcd-address-option
vitalif:rdma-zerocopy
vitalif:rel-0.5
vitalif:openonload
vitalif:sync-io-test
vitalif:trace-sync
vitalif:trace-sqes
vitalif:test-submit-and-wait
vitalif:test-sq-poll
vitalif:blocking-uring-test
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "koolkhel/vitastor:nbd-backend-identifier"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
netlink-revive /dev/nbdN --image othersilently attached a dead netlink device to another image: it exited 0, the device read the other image, and writes went there. A filesystem mounted from the device ends up corrupting both images.The kernel already guards against this. A RECONFIGURE whose
NBD_ATTR_BACKEND_IDENTIFIERdiffers from the one given on CONNECT fails withbackend image doesn't match with ..., and one without it fails withmust specify backend. But vitastor-nbd never sent the attribute. The code was under#ifdef NBD_ATTR_BACKEND_IDENTIFIER, which is an enum value inlinux/nbd-netlink.hand never defined, and the caller passedNULLanyway.This PR:
check_c_source_compiles(HAVE_NBD_BACKEND_IDENTIFIER), since#ifdefcan't see an enum value. Headers older than Linux 5.6 build without it, as before;"<pool>:<inode>"onnetlink-mapandnetlink-revive;netlink-revivesection ofdocs/usage/nbd.*.md;tests/test_nbd_netlink_revive.sh: map an image,kill -9the daemon, check that a revive with another image fails and one with the same image restores the data.Choices I made, happy to change them:
<pool>:<inode>, not the image name. It survives a rename, and a device mapped with--imagecan be revived with--pool --inodeand back. The name would read better in/sys/block/nbdN/backend, but after a rename the device could no longer be revived at all. Switching to the name is a one-line change.must specify backend. I don't see a way around that short of not sending the identifier.Tested as root on kernel 6.8 against a local 3-OSD cluster (
tests/run_3osds.sh):netlink-revive attached /dev/nbd0 of testimg to testimg2.backend image doesn't match with 1:1. Revive with the same image, by--imageor by--pool 1 --inode 1 --size ...: exit 0, the device reads the image.map,netlink-map, busy devices, resize, revive afterkill -9andunmapwork as before.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.