[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 11 Sep 2019 22:39:05 +1000
From: Matthew Bobrowski <mbobrowski@...browski.org>
To: Ritesh Harjani <riteshh@...ux.ibm.com>
Cc: tytso@....edu, jack@...e.cz, adilger.kernel@...ger.ca,
linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
david@...morbit.com, hch@...radead.org, darrick.wong@...cle.com
Subject: Re: [PATCH v2 5/6] ext4: introduce direct IO write path using iomap
infrastructure
On Wed, Sep 11, 2019 at 01:38:52PM +0530, Ritesh Harjani wrote:
> On 9/9/19 2:56 PM, Ritesh Harjani wrote:
> > On 9/9/19 4:49 AM, Matthew Bobrowski wrote:
> > > @@ -217,6 +218,14 @@ static ssize_t ext4_write_checks(struct kiocb
> > > *iocb, struct iov_iter *from)
> > > if (ret <= 0)
> > > return ret;
> > >
> > > + ret = file_remove_privs(iocb->ki_filp);
> > > + if (ret)
> > > + return 0;
> > > +
> > > + ret = file_update_time(iocb->ki_filp);
> > > + if (ret)
> > > + return 0;
> > > +
> > > if (unlikely(IS_IMMUTABLE(inode)))
> > > return -EPERM;
>
> Maybe we can move this up. If file is IMMUTABLE no point in
> calling for above actions (file_remove_privs/file_updatetime).
Yep, sure could do this. In fact, I think we could put this above
generic_write_checks().
> Also why not use file_modified() API which does the same.
Ah, nice. Indeed we can, thanks for simplifying it.
> > > @@ -234,6 +243,34 @@ static ssize_t ext4_write_checks(struct kiocb
> > > *iocb, struct iov_iter *from)
> > > return iov_iter_count(from);
> > > }
> > >
> > > +static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,
> > > + struct iov_iter *from)
> > > +{
> > > + ssize_t ret;
> > > + struct inode *inode = file_inode(iocb->ki_filp);
> > > +
> > > + if (iocb->ki_flags & IOCB_NOWAIT)
> > > + return -EOPNOTSUPP;
> > > +
> > > + if (!inode_trylock(inode))
> > > + inode_lock(inode);
>
> Is it really needed to check for trylock first?
> we can directly call for inode_lock() here.
You're right, no need to do this dance. We can call inode_lock() directly.
> > > +
> > > + ret = ext4_write_checks(iocb, from);
> > > + if (ret <= 0)
> > > + goto out;
> > > +
> > > + current->backing_dev_info = inode_to_bdi(inode);
> > > + ret = generic_perform_write(iocb->ki_filp, from, iocb->ki_pos);
> > > + current->backing_dev_info = NULL;
> > > +out:
> > > + inode_unlock(inode);
> > > + if (likely(ret > 0)) {
> > > + iocb->ki_pos += ret;
> > > + ret = generic_write_sync(iocb, ret);
> > > + }
> > > + return ret;
> > > +}
> > > +
> > > + if (!ext4_dio_checks(inode)) {
> > > + inode_unlock(inode);
> > > + /*
> > > + * Fallback to buffered IO if the operation on the
> > > + * inode is not supported by direct IO.
> > > + */
> > > + return ext4_buffered_write_iter(iocb, from);
> > > + }
> > > +
> > > + ret = ext4_write_checks(iocb, from);
> This can modify the count in iov_iter *from.
Good point. We'll recalculate the iter 'count' again.
Thank you for the review/suggestions, highly appreciated.
--<M>--
Powered by blists - more mailing lists