Commit 8fc32c2b authored by Jan Kara's avatar Jan Kara

quota: Push dqio_sem down to ->write_dqblk()

Push down acquisition of dqio_sem into ->write_dqblk() callback. It will
allow quota formats to decide whether they need it or not.
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 47cdc11d
...@@ -412,14 +412,14 @@ int dquot_acquire(struct dquot *dquot) ...@@ -412,14 +412,14 @@ int dquot_acquire(struct dquot *dquot)
set_bit(DQ_READ_B, &dquot->dq_flags); set_bit(DQ_READ_B, &dquot->dq_flags);
/* Instantiate dquot if needed */ /* Instantiate dquot if needed */
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
down_write(&dqopt->dqio_sem);
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
/* Write the info if needed */ /* Write the info if needed */
if (info_dirty(&dqopt->info[dquot->dq_id.type])) { if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
down_write(&dqopt->dqio_sem);
ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info( ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
dquot->dq_sb, dquot->dq_id.type); dquot->dq_sb, dquot->dq_id.type);
up_write(&dqopt->dqio_sem);
} }
up_write(&dqopt->dqio_sem);
if (ret < 0) if (ret < 0)
goto out_iolock; goto out_iolock;
if (ret2 < 0) { if (ret2 < 0) {
...@@ -456,13 +456,10 @@ int dquot_commit(struct dquot *dquot) ...@@ -456,13 +456,10 @@ int dquot_commit(struct dquot *dquot)
spin_unlock(&dq_list_lock); spin_unlock(&dq_list_lock);
/* Inactive dquot can be only if there was error during read/init /* Inactive dquot can be only if there was error during read/init
* => we have better not writing it */ * => we have better not writing it */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
down_write(&dqopt->dqio_sem);
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
up_write(&dqopt->dqio_sem); else
} else {
ret = -EIO; ret = -EIO;
}
out_lock: out_lock:
mutex_unlock(&dquot->dq_lock); mutex_unlock(&dquot->dq_lock);
return ret; return ret;
......
...@@ -83,7 +83,9 @@ static int v1_commit_dqblk(struct dquot *dquot) ...@@ -83,7 +83,9 @@ static int v1_commit_dqblk(struct dquot *dquot)
short type = dquot->dq_id.type; short type = dquot->dq_id.type;
ssize_t ret; ssize_t ret;
struct v1_disk_dqblk dqblk; struct v1_disk_dqblk dqblk;
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
down_write(&dqopt->dqio_sem);
v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) || if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) { ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
...@@ -97,6 +99,7 @@ static int v1_commit_dqblk(struct dquot *dquot) ...@@ -97,6 +99,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
(char *)&dqblk, sizeof(struct v1_disk_dqblk), (char *)&dqblk, sizeof(struct v1_disk_dqblk),
v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id))); v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
up_write(&dqopt->dqio_sem);
if (ret != sizeof(struct v1_disk_dqblk)) { if (ret != sizeof(struct v1_disk_dqblk)) {
quota_error(dquot->dq_sb, "dquota write failed"); quota_error(dquot->dq_sb, "dquota write failed");
if (ret >= 0) if (ret >= 0)
......
...@@ -298,7 +298,15 @@ static int v2_read_dquot(struct dquot *dquot) ...@@ -298,7 +298,15 @@ static int v2_read_dquot(struct dquot *dquot)
static int v2_write_dquot(struct dquot *dquot) static int v2_write_dquot(struct dquot *dquot)
{ {
return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot); struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
int ret;
down_write(&dqopt->dqio_sem);
ret = qtree_write_dquot(
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
dquot);
up_write(&dqopt->dqio_sem);
return ret;
} }
static int v2_release_dquot(struct dquot *dquot) static int v2_release_dquot(struct dquot *dquot)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment