From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Goldwyn Rodrigues <rgoldwyn@suse.de>,
linux-btrfs@vger.kernel.org
Cc: lkp@intel.com, kbuild-all@lists.01.org,
Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [kbuild] Re: [PATCH v3] btrfs: Make btrfs_direct_write atomic with respect to inode_lock
Date: Mon, 4 Jan 2021 13:10:22 +0300 [thread overview]
Message-ID: <20210104101022.GS2831@kadam> (raw)
In-Reply-To: <8846c296bcd4d5d3c21c6a98ee467ab5060c6757.1608307404.git.rgoldwyn@suse.com>
[-- Attachment #1: Type: text/plain, Size: 7349 bytes --]
Hi Goldwyn,
url: https://github.com/0day-ci/linux/commits/Goldwyn-Rodrigues/btrfs-Make-btrfs_direct_write-atomic-with-respect-to-inode_lock/20201219-001114
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: x86_64-randconfig-m001-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
fs/btrfs/file.c:1980 btrfs_direct_write() error: uninitialized symbol 'dsync'.
Old smatch warnings:
fs/btrfs/file.c:1865 __btrfs_buffered_write() error: uninitialized symbol 'ret'.
fs/btrfs/file.c:2013 btrfs_direct_write() error: uninitialized symbol 'dsync'.
vim +/dsync +1980 fs/btrfs/file.c
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1910 static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
d0215f3e5ebb580 Josef Bacik 2011-01-25 1911 {
d0215f3e5ebb580 Josef Bacik 2011-01-25 1912 struct file *file = iocb->ki_filp;
728404dacfddb53 Filipe Manana 2014-10-10 1913 struct inode *inode = file_inode(file);
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1914 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1915 loff_t pos;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1916 ssize_t written = 0;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1917 ssize_t written_buffered;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1918 loff_t endbyte;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1919 ssize_t err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1920 unsigned int ilock_flags = 0;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1921 struct iomap_dio *dio = NULL;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1922 bool dsync;
^^^^^^^^^^
This needs to be "bool dsync = false;"
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1923
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1924 if (iocb->ki_flags & IOCB_NOWAIT)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1925 ilock_flags |= BTRFS_ILOCK_TRY;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1926
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1927 /* If the write DIO is within EOF, use a shared lock */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1928 if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode))
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1929 ilock_flags |= BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1930
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1931 relock:
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1932 err = btrfs_inode_lock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1933 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1934 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1935
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1936 err = generic_write_checks(iocb, from);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1937 if (err <= 0) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1938 btrfs_inode_unlock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1939 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1940 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1941
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1942 err = btrfs_write_check(iocb, from, err);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1943 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1944 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1945
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1946 pos = iocb->ki_pos;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1947 /*
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1948 * Re-check since file size may have changed just before taking the
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1949 * lock or pos may have changed because of O_APPEND in generic_write_check()
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1950 */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1951 if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1952 pos + iov_iter_count(from) > i_size_read(inode)) {
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1953 btrfs_inode_unlock(inode, ilock_flags);
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1954 ilock_flags &= ~BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1955 goto relock;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1956 }
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1957
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1958 if (check_direct_IO(fs_info, from, pos))
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1959 goto buffered;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1960
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1961 dio = __iomap_dio_rw(iocb, from, &btrfs_dio_iomap_ops,
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1962 &btrfs_dio_ops, is_sync_kiocb(iocb));
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1963
d0215f3e5ebb580 Josef Bacik 2011-01-25 1964
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1965 if (IS_ERR_OR_NULL(dio)) {
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1966 err = PTR_ERR_OR_ZERO(dio);
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1967 if (err < 0 && err != -ENOTBLK)
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1968 goto out;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1969 } else {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1970 /*
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1971 * Remove the DSYNC flag because iomap_dio_complete() calls
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1972 * generic_write_sync() which may deadlock with btrfs_sync()
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1973 * on inode->i_rwsem
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1974 */
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1975 if (iocb->ki_flags & IOCB_DSYNC) {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1976 dsync = true;
^^^^^^^^^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1977 iocb->ki_flags &= ~IOCB_DSYNC;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1978 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1979 written = iomap_dio_complete(dio);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 @1980 if (dsync)
^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1981 iocb->ki_flags |= IOCB_DSYNC;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1982 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1983
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1984 if (written < 0 || !iov_iter_count(from)) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1985 err = written;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1986 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1987 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1988
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39286 bytes --]
[-- Attachment #3: Type: text/plain, Size: 149 bytes --]
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH v3] btrfs: Make btrfs_direct_write atomic with respect to inode_lock
Date: Mon, 04 Jan 2021 13:10:22 +0300 [thread overview]
Message-ID: <20210104101022.GS2831@kadam> (raw)
In-Reply-To: <8846c296bcd4d5d3c21c6a98ee467ab5060c6757.1608307404.git.rgoldwyn@suse.com>
[-- Attachment #1: Type: text/plain, Size: 7617 bytes --]
Hi Goldwyn,
url: https://github.com/0day-ci/linux/commits/Goldwyn-Rodrigues/btrfs-Make-btrfs_direct_write-atomic-with-respect-to-inode_lock/20201219-001114
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: x86_64-randconfig-m001-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
fs/btrfs/file.c:1980 btrfs_direct_write() error: uninitialized symbol 'dsync'.
Old smatch warnings:
fs/btrfs/file.c:1865 __btrfs_buffered_write() error: uninitialized symbol 'ret'.
fs/btrfs/file.c:2013 btrfs_direct_write() error: uninitialized symbol 'dsync'.
vim +/dsync +1980 fs/btrfs/file.c
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1910 static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
d0215f3e5ebb580 Josef Bacik 2011-01-25 1911 {
d0215f3e5ebb580 Josef Bacik 2011-01-25 1912 struct file *file = iocb->ki_filp;
728404dacfddb53 Filipe Manana 2014-10-10 1913 struct inode *inode = file_inode(file);
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1914 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1915 loff_t pos;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1916 ssize_t written = 0;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1917 ssize_t written_buffered;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1918 loff_t endbyte;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1919 ssize_t err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1920 unsigned int ilock_flags = 0;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1921 struct iomap_dio *dio = NULL;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1922 bool dsync;
^^^^^^^^^^
This needs to be "bool dsync = false;"
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1923
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1924 if (iocb->ki_flags & IOCB_NOWAIT)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1925 ilock_flags |= BTRFS_ILOCK_TRY;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1926
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1927 /* If the write DIO is within EOF, use a shared lock */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1928 if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode))
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1929 ilock_flags |= BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1930
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1931 relock:
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1932 err = btrfs_inode_lock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1933 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1934 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1935
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1936 err = generic_write_checks(iocb, from);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1937 if (err <= 0) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1938 btrfs_inode_unlock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1939 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1940 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1941
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1942 err = btrfs_write_check(iocb, from, err);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1943 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1944 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1945
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1946 pos = iocb->ki_pos;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1947 /*
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1948 * Re-check since file size may have changed just before taking the
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1949 * lock or pos may have changed because of O_APPEND in generic_write_check()
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1950 */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1951 if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1952 pos + iov_iter_count(from) > i_size_read(inode)) {
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1953 btrfs_inode_unlock(inode, ilock_flags);
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1954 ilock_flags &= ~BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1955 goto relock;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1956 }
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1957
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1958 if (check_direct_IO(fs_info, from, pos))
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1959 goto buffered;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1960
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1961 dio = __iomap_dio_rw(iocb, from, &btrfs_dio_iomap_ops,
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1962 &btrfs_dio_ops, is_sync_kiocb(iocb));
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1963
d0215f3e5ebb580 Josef Bacik 2011-01-25 1964
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1965 if (IS_ERR_OR_NULL(dio)) {
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1966 err = PTR_ERR_OR_ZERO(dio);
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1967 if (err < 0 && err != -ENOTBLK)
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1968 goto out;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1969 } else {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1970 /*
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1971 * Remove the DSYNC flag because iomap_dio_complete() calls
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1972 * generic_write_sync() which may deadlock with btrfs_sync()
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1973 * on inode->i_rwsem
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1974 */
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1975 if (iocb->ki_flags & IOCB_DSYNC) {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1976 dsync = true;
^^^^^^^^^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1977 iocb->ki_flags &= ~IOCB_DSYNC;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1978 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1979 written = iomap_dio_complete(dio);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 @1980 if (dsync)
^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1981 iocb->ki_flags |= IOCB_DSYNC;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1982 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1983
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1984 if (written < 0 || !iov_iter_count(from)) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1985 err = written;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1986 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1987 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1988
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 39286 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [kbuild] Re: [PATCH v3] btrfs: Make btrfs_direct_write atomic with respect to inode_lock
Date: Mon, 04 Jan 2021 13:10:22 +0300 [thread overview]
Message-ID: <20210104101022.GS2831@kadam> (raw)
In-Reply-To: <8846c296bcd4d5d3c21c6a98ee467ab5060c6757.1608307404.git.rgoldwyn@suse.com>
[-- Attachment #1: Type: text/plain, Size: 7617 bytes --]
Hi Goldwyn,
url: https://github.com/0day-ci/linux/commits/Goldwyn-Rodrigues/btrfs-Make-btrfs_direct_write-atomic-with-respect-to-inode_lock/20201219-001114
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: x86_64-randconfig-m001-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
fs/btrfs/file.c:1980 btrfs_direct_write() error: uninitialized symbol 'dsync'.
Old smatch warnings:
fs/btrfs/file.c:1865 __btrfs_buffered_write() error: uninitialized symbol 'ret'.
fs/btrfs/file.c:2013 btrfs_direct_write() error: uninitialized symbol 'dsync'.
vim +/dsync +1980 fs/btrfs/file.c
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1910 static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
d0215f3e5ebb580 Josef Bacik 2011-01-25 1911 {
d0215f3e5ebb580 Josef Bacik 2011-01-25 1912 struct file *file = iocb->ki_filp;
728404dacfddb53 Filipe Manana 2014-10-10 1913 struct inode *inode = file_inode(file);
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1914 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1915 loff_t pos;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1916 ssize_t written = 0;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1917 ssize_t written_buffered;
d0215f3e5ebb580 Josef Bacik 2011-01-25 1918 loff_t endbyte;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1919 ssize_t err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1920 unsigned int ilock_flags = 0;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1921 struct iomap_dio *dio = NULL;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1922 bool dsync;
^^^^^^^^^^
This needs to be "bool dsync = false;"
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1923
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1924 if (iocb->ki_flags & IOCB_NOWAIT)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1925 ilock_flags |= BTRFS_ILOCK_TRY;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1926
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1927 /* If the write DIO is within EOF, use a shared lock */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1928 if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode))
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1929 ilock_flags |= BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1930
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1931 relock:
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1932 err = btrfs_inode_lock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1933 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1934 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1935
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1936 err = generic_write_checks(iocb, from);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1937 if (err <= 0) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1938 btrfs_inode_unlock(inode, ilock_flags);
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1939 return err;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1940 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1941
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1942 err = btrfs_write_check(iocb, from, err);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1943 if (err < 0)
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1944 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1945
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1946 pos = iocb->ki_pos;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1947 /*
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1948 * Re-check since file size may have changed just before taking the
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1949 * lock or pos may have changed because of O_APPEND in generic_write_check()
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1950 */
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1951 if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1952 pos + iov_iter_count(from) > i_size_read(inode)) {
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1953 btrfs_inode_unlock(inode, ilock_flags);
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1954 ilock_flags &= ~BTRFS_ILOCK_SHARED;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1955 goto relock;
e9adabb9712ef94 Goldwyn Rodrigues 2020-09-24 1956 }
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1957
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1958 if (check_direct_IO(fs_info, from, pos))
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1959 goto buffered;
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1960
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1961 dio = __iomap_dio_rw(iocb, from, &btrfs_dio_iomap_ops,
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1962 &btrfs_dio_ops, is_sync_kiocb(iocb));
4e4cabece9f9c6b Goldwyn Rodrigues 2020-09-24 1963
d0215f3e5ebb580 Josef Bacik 2011-01-25 1964
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1965 if (IS_ERR_OR_NULL(dio)) {
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1966 err = PTR_ERR_OR_ZERO(dio);
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1967 if (err < 0 && err != -ENOTBLK)
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1968 goto out;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1969 } else {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1970 /*
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1971 * Remove the DSYNC flag because iomap_dio_complete() calls
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1972 * generic_write_sync() which may deadlock with btrfs_sync()
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1973 * on inode->i_rwsem
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1974 */
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1975 if (iocb->ki_flags & IOCB_DSYNC) {
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1976 dsync = true;
^^^^^^^^^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1977 iocb->ki_flags &= ~IOCB_DSYNC;
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1978 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1979 written = iomap_dio_complete(dio);
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 @1980 if (dsync)
^^^^^
e7a8dd2d9537a7e Goldwyn Rodrigues 2020-12-18 1981 iocb->ki_flags |= IOCB_DSYNC;
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1982 }
a42fa643169d232 Goldwyn Rodrigues 2020-09-24 1983
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1984 if (written < 0 || !iov_iter_count(from)) {
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1985 err = written;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1986 goto out;
c352370633400d1 Goldwyn Rodrigues 2020-09-24 1987 }
d0215f3e5ebb580 Josef Bacik 2011-01-25 1988
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 39286 bytes --]
next prev parent reply other threads:[~2021-01-04 10:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-18 16:07 [PATCH v3] btrfs: Make btrfs_direct_write atomic with respect to inode_lock Goldwyn Rodrigues
2020-12-19 17:50 ` kernel test robot
2020-12-19 17:50 ` kernel test robot
2020-12-24 3:10 ` [btrfs] e7a8dd2d95: fio.write_iops -98.3% regression kernel test robot
2020-12-24 3:10 ` kernel test robot
2021-01-04 10:10 ` Dan Carpenter [this message]
2021-01-04 10:10 ` [kbuild] Re: [PATCH v3] btrfs: Make btrfs_direct_write atomic with respect to inode_lock Dan Carpenter
2021-01-04 10:10 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210104101022.GS2831@kadam \
--to=dan.carpenter@oracle.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=lkp@intel.com \
--cc=rgoldwyn@suse.com \
--cc=rgoldwyn@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.