return 0;
}
-// image locking
/**
* helper function to add a lock and update disk state.
- * @param lock_type The type of lock, either RBD_LOCK_EXCLUSIVE
- * or RBD_LOCK_SHARED
+ *
+ * Input:
+ * @param lock_type The type of lock, either RBD_LOCK_EXCLUSIVE or RBD_LOCK_SHARED
* @param cookie The cookie to set in the lock
*
* @return 0 on success, or -errno on failure
const string &cookie)
{
bool exclusive = lock_type == RBD_LOCK_EXCLUSIVE;
+
// see if there's already a locker
set<pair<string, string> > lockers;
string existing_lock_type;
}
return r;
}
+
/**
* Set an exclusive lock on an image for the activating client, if possible.
+ *
* Input:
* @param lock_cookie A string cookie, defined by the locker.
*
/**
* Set an exclusive lock on an image, if possible.
+ *
* Input:
* @param lock_cookie A string cookie, defined by the locker.
*
return lock_image(hctx, RBD_LOCK_SHARED, lock_cookie);
}
+
/**
* helper function to remove a lock from on disk and clean up state.
+ *
* @param inst The string representation of the locker's entity.
* @param cookie The user-defined cookie associated with the lock.
*
return 0;
}
+
/**
* Unlock an image which the activating client currently has locked.
+ *
* Input:
* @param lock_cookie The user-defined cookie associated with the lock.
*
inst_stringstream << inst;
return remove_lock(hctx, inst_stringstream.str(), lock_cookie);
}
+
/**
* Break the lock on an image held by any client.
+ *
* Input:
* @param locker The string representation of the locking client's entity.
* @param lock_cookie The user-defined cookie associated with the lock.
* @return 0 on success, -EINVAL if it can't decode the locker and
* cookie, -ENOENT if there is no such lock (either entity or cookie
* is wrong), or -errno on other (unexpected) error.
- */int break_lock(cls_method_context_t hctx,
+ */
+int break_lock(cls_method_context_t hctx,
bufferlist *in, bufferlist *out)
{
CLS_LOG(20, "break_lock");
/**
* Retrieve a list of clients locking this object (presumably an rbd header),
* as well as whether the lock is shared or exclusive.
+ *
+ * Input:
* @param in is ignored.
+ *
* Output:
* @param set<pair<string, string> > lockers The set of clients holding locks,
* as <client, cookie> pairs.
}
/**
+ * get the current parent, if any
+ *
* Input:
* @param snap_id which snapshot to query, or CEPH_NOSNAP (uint64_t)
*
* @param image parent image id
* @param snapid parent snapid
* @param size portion of parent mapped under the child
- * @returns 0 on success, negative error code on failure
+ *
+ * @returns 0 on success, -ENOENT if no parent, other negative error code on failure
*/
int get_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
/**
* set the image parent
*
+ * Input:
* @param pool parent pool
* @param id parent image id
* @param snapid parent snapid
* @param size parent size
+ *
* @returns 0 on success, or negative error code
*/
int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)