#define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW)
#define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW)
#define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX)
+#define LCK_COMPAT_GROUP (LCK_GROUP | LCK_NL)
static ldlm_mode_t lck_compat_array[] = {
[LCK_EX] LCK_COMPAT_EX,
[LCK_PR] LCK_COMPAT_PR,
[LCK_CW] LCK_COMPAT_CW,
[LCK_CR] LCK_COMPAT_CR,
- [LCK_NL] LCK_COMPAT_NL
+ [LCK_NL] LCK_COMPAT_NL,
+ [LCK_GROUP] LCK_COMPAT_GROUP
};
static inline void lockmode_verify(ldlm_mode_t mode)
{
- LASSERT(mode >= LCK_EX && mode <= LCK_NL);
+ LASSERT(mode >= LCK_EX && mode <= LCK_GROUP);
}
static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new)
LCK_PR = 4,
LCK_CW = 8,
LCK_CR = 16,
- LCK_NL = 32
+ LCK_NL = 32,
+ LCK_GROUP = 64
} ldlm_mode_t;
struct ldlm_extent {
#define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
#define LL_IOC_LOV_SETEA _IOW ('f', 156, long)
#define LL_IOC_RECREATE_OBJ _IOW ('f', 157, long)
-#define LL_IOC_CW_LOCK _IOW ('f', 158, long)
-#define LL_IOC_CW_UNLOCK _IOW ('f', 159, long)
+#define LL_IOC_GROUP_LOCK _IOW ('f', 158, long)
+#define LL_IOC_GROUP_UNLOCK _IOW ('f', 159, long)
#define O_LOV_DELAY_CREATE 0100000000 /* hopefully this does not conflict */
#define LL_FILE_IGNORE_LOCK 0x00000001
-#define LL_FILE_CW_LOCKED 0x00000002
+#define LL_FILE_GROUP_LOCKED 0x00000002
#define LOV_USER_MAGIC_V1 0x0BD10BD0
#define LOV_USER_MAGIC LOV_USER_MAGIC_V1
/* locks are compatible, overlap doesn't matter */
if (lockmode_compat(lock->l_req_mode, req_mode)) {
- /* nonCW locks are compatible, overlap doesn't matter */
- if (req_mode != LCK_CW)
+ /* non-group locks are compatible, overlap doesn't
+ matter */
+ if (req_mode != LCK_GROUP)
continue;
- /* If we are trying to get a CW lock and there is
+ /* If we are trying to get a GROUP lock and there is
another one of this kind, we need to compare gid */
if (req->l_policy_data.l_extent.gid ==
- lock->l_policy_data.l_extent.gid) {
+ lock->l_policy_data.l_extent.gid) {
if (lock->l_req_mode == lock->l_granted_mode)
RETURN(2);
}
}
- if (lock->l_req_mode == LCK_CW) {
- /* If compared lock is CW, then requested is PR/PW/ =>
+ if (lock->l_req_mode == LCK_GROUP) {
+ /* If compared lock is GROUP, then requested is PR/PW/=>
* this is not compatible; extent range does not
* matter */
if (*flags & LDLM_FL_BLOCK_NOWAIT) {
}
} else if (lock->l_policy_data.l_extent.end < req_start ||
lock->l_policy_data.l_extent.start > req_end) {
- /* if a non-CW lock doesn't overlap skip it */
+ /* if a non grouplock doesn't overlap skip it */
continue;
}
[LCK_PR] "PR",
[LCK_CW] "CW",
[LCK_CR] "CR",
- [LCK_NL] "NL"
+ [LCK_NL] "NL",
+ [LCK_GROUP] "GROUP"
};
char *ldlm_typename[] = {
[LDLM_PLAIN] "PLN",
ldlm_lock_remove_from_lru(lock);
if (mode & (LCK_NL | LCK_CR | LCK_PR))
lock->l_readers++;
- if (mode & (LCK_EX | LCK_CW | LCK_PW))
+ if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP))
lock->l_writers++;
lock->l_last_used = jiffies;
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
LASSERT(lock->l_readers > 0);
lock->l_readers--;
}
- if (mode & (LCK_EX | LCK_CW | LCK_PW)) {
+ if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP)) {
LASSERT(lock->l_writers > 0);
lock->l_writers--;
}
continue;
if (lock->l_resource->lr_type == LDLM_EXTENT &&
- mode == LCK_CW &&
+ mode == LCK_GROUP &&
lock->l_policy_data.l_extent.gid != policy->l_extent.gid)
continue;
l_pending_chain);
if ((lock->l_callback_timeout > jiffies) ||
- (lock->l_req_mode == LCK_CW))
+ (lock->l_req_mode == LCK_GROUP))
break;
LDLM_ERROR(lock, "lock callback timer expired: evicting client "
ENTRY;
/* clear group lock, if present */
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
struct lov_stripe_md *lsm = llu_i2info(inode)->lli_smd;
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
- rc = llu_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
+ rc = llu_extent_unlock(fd, inode, lsm, LCK_GROUP,
+ &fd->fd_cwlockh);
}
valid = OBD_MD_FLID;
return -ENOSYS;
}
-static int llu_get_cwlock(struct inode *inode, unsigned long arg)
+static int llu_get_grouplock(struct inode *inode, unsigned long arg)
{
struct llu_inode_info *lli = llu_i2info(inode);
struct ll_file_data *fd = lli->lli_file_data;
int flags = 0;
ENTRY;
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
RETURN(-EINVAL);
}
if (lli->lli_open_flags & O_NONBLOCK)
flags = LDLM_FL_BLOCK_NOWAIT;
- err = llu_extent_lock(fd, inode, lsm, LCK_CW, &policy, &lockh, flags);
+ err = llu_extent_lock(fd, inode, lsm, LCK_GROUP, &policy, &lockh,
+ flags);
if (err)
RETURN(err);
- fd->fd_flags |= LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK;
+ fd->fd_flags |= LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK;
fd->fd_gid = arg;
memcpy(&fd->fd_cwlockh, &lockh, sizeof(lockh));
RETURN(0);
}
-static int llu_put_cwlock(struct inode *inode, unsigned long arg)
+static int llu_put_grouplock(struct inode *inode, unsigned long arg)
{
struct llu_inode_info *lli = llu_i2info(inode);
struct ll_file_data *fd = lli->lli_file_data;
ldlm_error_t err;
ENTRY;
- if (!(fd->fd_flags & LL_FILE_CW_LOCKED))
+ if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED))
RETURN(-EINVAL);
if (fd->fd_gid != arg)
RETURN(-EINVAL);
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
- err = llu_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
+ err = llu_extent_unlock(fd, inode, lsm, LCK_GROUP, &fd->fd_cwlockh);
if (err)
RETURN(err);
unsigned long arg;
switch (request) {
- case LL_IOC_CW_LOCK:
+ case LL_IOC_GROUP_LOCK:
arg = va_arg(ap, unsigned long);
- return llu_get_cwlock(ino, arg);
- case LL_IOC_CW_UNLOCK:
+ return llu_get_grouplock(ino, arg);
+ case LL_IOC_GROUP_UNLOCK:
arg = va_arg(ap, unsigned long);
- return llu_put_cwlock(ino, arg);
+ return llu_put_grouplock(ino, arg);
}
CERROR("did not support ioctl cmd %lx\n", request);
ENTRY;
/* clear group lock, if present */
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
- rc = ll_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
+ rc = ll_extent_unlock(fd, inode, lsm, LCK_GROUP,
+ &fd->fd_cwlockh);
}
valid = OBD_MD_FLID;
(void *)arg);
}
-static int ll_get_cwlock(struct inode *inode, struct file *file,
+static int ll_get_grouplock(struct inode *inode, struct file *file,
unsigned long arg)
{
struct ll_file_data *fd = file->private_data;
int flags = 0;
ENTRY;
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
RETURN(-EINVAL);
}
if (file->f_flags & O_NONBLOCK)
flags = LDLM_FL_BLOCK_NOWAIT;
- err = ll_extent_lock(fd, inode, lsm, LCK_CW, &policy, &lockh, flags);
+ err = ll_extent_lock(fd, inode, lsm, LCK_GROUP, &policy, &lockh, flags);
if (err)
RETURN(err);
- fd->fd_flags |= LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK;
+ fd->fd_flags |= LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK;
fd->fd_gid = arg;
memcpy(&fd->fd_cwlockh, &lockh, sizeof(lockh));
RETURN(0);
}
-static int ll_put_cwlock(struct inode *inode, struct file *file,
+static int ll_put_grouplock(struct inode *inode, struct file *file,
unsigned long arg)
{
struct ll_file_data *fd = file->private_data;
ldlm_error_t err;
ENTRY;
- if (!(fd->fd_flags & LL_FILE_CW_LOCKED)) {
+ if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
/* Ugh, it's already unlocked. */
RETURN(-EINVAL);
}
if (fd->fd_gid != arg) /* Ugh? Unlocking with different gid? */
RETURN(-EINVAL);
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
- err = ll_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
+ err = ll_extent_unlock(fd, inode, lsm, LCK_GROUP, &fd->fd_cwlockh);
if (err)
RETURN(err);
case EXT3_IOC_GETFLAGS:
case EXT3_IOC_SETFLAGS:
RETURN( ll_iocontrol(inode, file, cmd, arg) );
- case LL_IOC_CW_LOCK:
- RETURN(ll_get_cwlock(inode, file, arg));
- case LL_IOC_CW_UNLOCK:
- RETURN(ll_put_cwlock(inode, file, arg));
+ case LL_IOC_GROUP_LOCK:
+ RETURN(ll_get_grouplock(inode, file, arg));
+ case LL_IOC_GROUP_UNLOCK:
+ RETURN(ll_put_grouplock(inode, file, arg));
/* We need to special case any other ioctls we want to handle,
* to send them to the MDS/OST as appropriate and to properly
* network encode the arg field.
int flags, matches;
ENTRY;
- if (fd_flags & LL_FILE_CW_LOCKED)
+ if (fd_flags & LL_FILE_GROUP_LOCKED)
RETURN(1);
page_extent.l_extent.start = (__u64)page->index << PAGE_CACHE_SHIFT;
{
ENTRY;
- if (mode == LCK_CW)
+ if (mode == LCK_GROUP)
ldlm_lock_decref_and_cancel(lockh, mode);
else
ldlm_lock_decref(lockh, mode);