used=`rbd -p ${POOL} --format xml du ${IMAGE} |
$XMLSTARLET sel -t -m "//stats/images/image/used_size" -v .`
[ "${used}" -lt "${provisioned}" ]
+unmap_device ${DEV} ${PID}
# resize test
+DEV=`_sudo rbd device -t nbd -o try-netlink map ${POOL}/${IMAGE}`
+get_pid ${POOL}
devname=$(basename ${DEV})
blocks=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions)
test -n "${blocks}"
blocks2=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions)
test -n "${blocks2}"
test ${blocks2} -eq ${blocks}
+unmap_device ${DEV} ${PID}
# read-only option test
-unmap_device ${DEV} ${PID}
DEV=`_sudo rbd --device-type nbd map --read-only ${POOL}/${IMAGE}`
PID=$(rbd device --device-type nbd list | awk -v pool=${POOL} -v img=${IMAGE} -v dev=${DEV} \
'$2 == pool && $3 == img && $5 == dev {print $1}')
static int parse_args(vector<const char*>& args, std::ostream *err_msg,
Config *cfg);
static int netlink_disconnect(int index);
-static int netlink_resize(int nbd_index, uint64_t size);
+static int netlink_resize(int nbd_index, const std::string& cookie,
+ uint64_t size);
static int run_quiesce_hook(const std::string &quiesce_hook,
const std::string &devpath,
ceph::mutex lock = ceph::make_mutex("NBDWatchCtx::Locker");
bool notify = false;
bool terminated = false;
+ std::string cookie;
bool wait_notify() {
dout(10) << __func__ << dendl;
<< dendl;
}
if (use_netlink) {
- ret = netlink_resize(nbd_index, new_size);
+ ret = netlink_resize(nbd_index, cookie, new_size);
} else {
ret = ioctl(fd, NBD_SET_SIZE, new_size);
if (ret < 0) {
- derr << "resize failed: " << cpp_strerror(errno) << dendl;
+ derr << "ioctl resize failed: " << cpp_strerror(errno) << dendl;
}
}
if (!ret) {
bool _use_netlink,
librados::IoCtx &_io_ctx,
librbd::Image &_image,
- unsigned long _size)
+ unsigned long _size,
+ std::string _cookie)
: fd(_fd)
, nbd_index(_nbd_index)
, use_netlink(_use_netlink)
, io_ctx(_io_ctx)
, image(_image)
, size(_size)
+ , cookie(std::move(_cookie))
{
handle_notify_thread = make_named_thread("rbd_handle_notify",
&NBDWatchCtx::handle_notify_entry,
return netlink_disconnect(index);
}
-static int netlink_resize(int nbd_index, uint64_t size)
+static int netlink_resize(int nbd_index, const std::string& cookie,
+ uint64_t size)
{
struct nl_sock *sock;
struct nl_msg *msg;
NLA_PUT_U32(msg, NBD_ATTR_INDEX, nbd_index);
NLA_PUT_U64(msg, NBD_ATTR_SIZE_BYTES, size);
+ if (!cookie.empty())
+ NLA_PUT_STRING(msg, NBD_ATTR_BACKEND_IDENTIFIER, cookie.c_str());
ret = nl_send_sync(sock, msg);
if (ret < 0) {
uint64_t handle;
NBDWatchCtx watch_ctx(nbd, nbd_index, use_netlink, io_ctx, image,
- info.size);
+ info.size, cfg->cookie);
r = image.update_watch(&watch_ctx, &handle);
if (r < 0)
goto close_nbd;