During setting quota, it should fail if the mount is read-only.
Change-Id: I966ac71d0a4a72dcb998f09ffc0f99ae28498e27
Signed-off-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43765
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
return 0;
}
-int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
+int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl)
{
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
int cmd = qctl->qc_cmd;
int type = qctl->qc_type;
int id = qctl->qc_id;
case LUSTRE_Q_SETDEFAULT_POOL:
if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
+
+ if (sb->s_flags & SB_RDONLY)
+ RETURN(-EROFS);
break;
case Q_GETQUOTA:
case LUSTRE_Q_GETDEFAULT:
GOTO(out_quotactl, rc = -EFAULT);
}
- rc = quotactl_ioctl(sbi, qctl);
+ rc = quotactl_ioctl(inode->i_sb, qctl);
if (rc == 0 &&
copy_to_user((void __user *)arg, qctl, sizeof(*qctl)))
rc = -EFAULT;
struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
__u64 offset);
void ll_release_page(struct inode *inode, struct page *page, bool remove);
-int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl);
+int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl);
/* llite/namei.c */
extern const struct inode_operations ll_special_inode_operations;
int ret;
qctl.qc_id = ll_i2info(inode)->lli_projid;
- ret = quotactl_ioctl(ll_i2sbi(inode), &qctl);
+ ret = quotactl_ioctl(inode->i_sb, &qctl);
if (ret) {
/* ignore errors if project ID does not have
* a quota limit or feature unsupported.
}
run_test 76 "project ID 4294967295 should be not allowed"
+test_77()
+{
+ mount_client $MOUNT2 "ro"
+ lfs setquota -u quota_usr -b 100M -B 100M -i 10K -I 10K $MOUNT2 &&
+ error "lfs setquota should fail in read-only Lustre mount"
+ umount $MOUNT2
+}
+run_test 77 "lfs setquota should fail in Lustre mount with 'ro'"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) \
obd_uuid2str(&qctl->obd_uuid), strerror(-rc));
}
out:
+ if (rc)
+ fprintf(stderr, "setquota failed: %s\n", strerror(-rc));
+
free(qctl);
return rc;
}