Skip to content

Commit

Permalink
btrfs-progs: constify the buffer pointer for write functions
Browse files Browse the repository at this point in the history
The following functions accept a buffer for write, which can be marked
as const:

- btrfs_pwrite()
- write_data_to_disk()

Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
adam900710 authored and kdave committed May 10, 2023
1 parent 8cb578b commit 32022eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions common/device-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ ssize_t btrfs_direct_pread(int fd, void *buf, size_t count, off_t offset);
ssize_t btrfs_direct_pwrite(int fd, const void *buf, size_t count, off_t offset);

#ifdef BTRFS_ZONED
static inline ssize_t btrfs_pwrite(int fd, void *buf, size_t count,
static inline ssize_t btrfs_pwrite(int fd, const void *buf, size_t count,
off_t offset, bool direct)
{
if (!direct)
return pwrite(fd, buf, count, offset);

return btrfs_direct_pwrite(fd, buf, count, offset);
}
static inline ssize_t btrfs_pread(int fd, void *buf, size_t count, off_t offset,
bool direct)
static inline ssize_t btrfs_pread(int fd, void *buf, size_t count,
off_t offset, bool direct)
{
if (!direct)
return pread(fd, buf, count, offset);
Expand Down
2 changes: 1 addition & 1 deletion kernel-shared/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 logical,
* Such data will be written to all mirrors and RAID56 P/Q will also be
* properly handled.
*/
int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
int write_data_to_disk(struct btrfs_fs_info *info, const void *buf, u64 offset,
u64 bytes)
{
struct btrfs_multi_bio *multi = NULL;
Expand Down
2 changes: 1 addition & 1 deletion kernel-shared/extent_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb);
int btrfs_clear_buffer_dirty(struct extent_buffer *eb);
int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 logical,
u64 *len, int mirror);
int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
int write_data_to_disk(struct btrfs_fs_info *info, const void *buf, u64 offset,
u64 bytes);
void extent_buffer_bitmap_clear(struct extent_buffer *eb, unsigned long start,
unsigned long pos, unsigned long len);
Expand Down

0 comments on commit 32022eb

Please sign in to comment.