Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b31dc66a authored by Jens Axboe's avatar Jens Axboe Committed by Jens Axboe
Browse files

[PATCH] Kill PF_SYNCWRITE flag



A process flag to indicate whether we are doing sync io is incredibly
ugly. It also causes performance problems when one does a lot of async
io and then proceeds to sync it. Part of the io will go out as async,
and the other part as sync. This causes a disconnect between the
previously submitted io and the synced io. For io schedulers such as CFQ,
this will cause us lost merges and suboptimal behaviour in scheduling.

Remove PF_SYNCWRITE completely from the fsync/msync paths, and let
the O_DIRECT path just directly indicate that the writes are sync
by using WRITE_SYNC instead.

Signed-off-by: default avatarJens Axboe <axboe@suse.de>
parent 271f18f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1339,7 +1339,7 @@ static void as_add_request(request_queue_t *q, struct request *rq)
	arq->state = AS_RQ_NEW;

	if (rq_data_dir(arq->request) == READ
			|| current->flags&PF_SYNCWRITE)
			|| (arq->request->flags & REQ_RW_SYNC))
		arq->is_sync = 1;
	else
		arq->is_sync = 0;
+1 −3
Original line number Diff line number Diff line
@@ -277,8 +277,6 @@ static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsi
static void cfq_dispatch_insert(request_queue_t *, struct cfq_rq *);
static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, unsigned int key, struct task_struct *tsk, gfp_t gfp_mask);

#define process_sync(tsk)	((tsk)->flags & PF_SYNCWRITE)

/*
 * lots of deadline iosched dupes, can be abstracted later...
 */
@@ -334,7 +332,7 @@ static int cfq_queue_empty(request_queue_t *q)

static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
{
	if (rw == READ || process_sync(task))
	if (rw == READ || rw == WRITE_SYNC)
		return task->pid;

	return CFQ_KEY_ASYNC;
+3 −0
Original line number Diff line number Diff line
@@ -2827,6 +2827,9 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
	if (unlikely(bio_barrier(bio)))
		req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE);

	if (bio_sync(bio))
		req->flags |= REQ_RW_SYNC;

	req->errors = 0;
	req->hard_sector = req->sector = bio->bi_sector;
	req->hard_nr_sectors = req->nr_sectors = bio_sectors(bio);
+0 −2
Original line number Diff line number Diff line
@@ -1906,7 +1906,6 @@ static int fsync_sub(struct lun *curlun)

	inode = filp->f_dentry->d_inode;
	mutex_lock(&inode->i_mutex);
	current->flags |= PF_SYNCWRITE;
	rc = filemap_fdatawrite(inode->i_mapping);
	err = filp->f_op->fsync(filp, filp->f_dentry, 1);
	if (!rc)
@@ -1914,7 +1913,6 @@ static int fsync_sub(struct lun *curlun)
	err = filemap_fdatawait(inode->i_mapping);
	if (!rc)
		rc = err;
	current->flags &= ~PF_SYNCWRITE;
	mutex_unlock(&inode->i_mutex);
	VLDBG(curlun, "fdatasync -> %d\n", rc);
	return rc;
+0 −2
Original line number Diff line number Diff line
@@ -331,7 +331,6 @@ long do_fsync(struct file *file, int datasync)
		goto out;
	}

	current->flags |= PF_SYNCWRITE;
	ret = filemap_fdatawrite(mapping);

	/*
@@ -346,7 +345,6 @@ long do_fsync(struct file *file, int datasync)
	err = filemap_fdatawait(mapping);
	if (!ret)
		ret = err;
	current->flags &= ~PF_SYNCWRITE;
out:
	return ret;
}
Loading