diff mbox series

[1/2] fs: introduce APIs to enable sending write-hint with buffer-head

Message ID 1544446204-5291-2-git-send-email-joshi.k@samsung.com (mailing list archive)
State New, archived
Headers show
Series fs,ext4,jbd2: Specifying write-hint for Ext4 journal | expand

Commit Message

Kanchan Joshi Dec. 10, 2018, 12:50 p.m. UTC
submit_bh and write_dirty_buffer do not take write-hint as
parameter. This patch introduces variants which do.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
 fs/buffer.c                 | 21 +++++++++++++++++++++
 include/linux/buffer_head.h |  3 +++
 2 files changed, 24 insertions(+)

Comments

Jan Kara Dec. 10, 2018, 1:49 p.m. UTC | #1
On Mon 10-12-18 18:20:03, Kanchan Joshi wrote:
> submit_bh and write_dirty_buffer do not take write-hint as
> parameter. This patch introduces variants which do.
> 
> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>

...

> @@ -3162,6 +3169,20 @@ void write_dirty_buffer(struct buffer_head *bh, int op_flags)
>  }
>  EXPORT_SYMBOL(write_dirty_buffer);
>  
> +void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags,
> +				   enum rw_hint hint)
> +{
> +	lock_buffer(bh);
> +	if (!test_clear_buffer_dirty(bh)) {
> +		unlock_buffer(bh);
> +		return;
> +	}
> +	bh->b_end_io = end_buffer_write_sync;
> +	get_bh(bh);
> +	submit_bh_wbc(REQ_OP_WRITE, op_flags, bh, hint, NULL);
> +}
> +EXPORT_SYMBOL(write_dirty_buffer_write_hint);
> +

Please implement write_dirty_buffer() as a call to
write_dirty_buffer_write_hint() so that we don't unnecessarily duplicate
the code. Otherwise the patch looks good.

								Honza
Kanchan Joshi Dec. 11, 2018, 11:57 a.m. UTC | #2
Thank you for review and suggestion.
I will make that change in V2, once things become clear for second patch
of this set.

On Monday 10 December 2018 07:19 PM, Jan Kara wrote:
> On Mon 10-12-18 18:20:03, Kanchan Joshi wrote:
>> submit_bh and write_dirty_buffer do not take write-hint as
>> parameter. This patch introduces variants which do.
>>
>> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> 
> ...
> 
>> @@ -3162,6 +3169,20 @@ void write_dirty_buffer(struct buffer_head *bh, int op_flags)
>>   }
>>   EXPORT_SYMBOL(write_dirty_buffer);
>>   
>> +void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags,
>> +				   enum rw_hint hint)
>> +{
>> +	lock_buffer(bh);
>> +	if (!test_clear_buffer_dirty(bh)) {
>> +		unlock_buffer(bh);
>> +		return;
>> +	}
>> +	bh->b_end_io = end_buffer_write_sync;
>> +	get_bh(bh);
>> +	submit_bh_wbc(REQ_OP_WRITE, op_flags, bh, hint, NULL);
>> +}
>> +EXPORT_SYMBOL(write_dirty_buffer_write_hint);
>> +
> 
> Please implement write_dirty_buffer() as a call to
> write_dirty_buffer_write_hint() so that we don't unnecessarily duplicate
> the code. Otherwise the patch looks good.
> 
> 								Honza
>
diff mbox series

Patch

diff --git a/fs/buffer.c b/fs/buffer.c
index 1286c2b..60c8867 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3094,6 +3094,13 @@  int submit_bh(int op, int op_flags, struct buffer_head *bh)
 }
 EXPORT_SYMBOL(submit_bh);
 
+int submit_bh_write_hint(int op, int op_flags, struct buffer_head *bh,
+			 enum rw_hint hint)
+{
+	return submit_bh_wbc(op, op_flags, bh, hint, NULL);
+}
+EXPORT_SYMBOL(submit_bh_write_hint);
+
 /**
  * ll_rw_block: low-level access to block devices (DEPRECATED)
  * @op: whether to %READ or %WRITE
@@ -3162,6 +3169,20 @@  void write_dirty_buffer(struct buffer_head *bh, int op_flags)
 }
 EXPORT_SYMBOL(write_dirty_buffer);
 
+void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags,
+				   enum rw_hint hint)
+{
+	lock_buffer(bh);
+	if (!test_clear_buffer_dirty(bh)) {
+		unlock_buffer(bh);
+		return;
+	}
+	bh->b_end_io = end_buffer_write_sync;
+	get_bh(bh);
+	submit_bh_wbc(REQ_OP_WRITE, op_flags, bh, hint, NULL);
+}
+EXPORT_SYMBOL(write_dirty_buffer_write_hint);
+
 /*
  * For a data-integrity writeout, we need to wait upon any in-progress I/O
  * and then start new I/O and then wait upon it.  The caller must have a ref on
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 7b73ef7..ac9f111 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -200,7 +200,10 @@  void ll_rw_block(int, int, int, struct buffer_head * bh[]);
 int sync_dirty_buffer(struct buffer_head *bh);
 int __sync_dirty_buffer(struct buffer_head *bh, int op_flags);
 void write_dirty_buffer(struct buffer_head *bh, int op_flags);
+void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags,
+				   enum rw_hint hint);
 int submit_bh(int, int, struct buffer_head *);
+int submit_bh_write_hint(int, int, struct buffer_head *, enum rw_hint hint);
 void write_boundary_block(struct block_device *bdev,
 			sector_t bblock, unsigned blocksize);
 int bh_uptodate_or_lock(struct buffer_head *bh);