@@ -1616,6 +1616,7 @@ static ssize_t ll_do_tiny_write(struct kiocb *iocb, struct iov_iter *iter)
ssize_t count = iov_iter_count(iter);
struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(file);
+ bool lock_inode = !IS_NOSEC(inode);
ssize_t result = 0;
/* Restrict writes to single page and < PAGE_SIZE. See comment at top
@@ -1625,8 +1626,13 @@ static ssize_t ll_do_tiny_write(struct kiocb *iocb, struct iov_iter *iter)
(iocb->ki_pos & (PAGE_SIZE-1)) + count > PAGE_SIZE)
return 0;
+ if (unlikely(lock_inode))
+ inode_lock(inode);
result = __generic_file_write_iter(iocb, iter);
+ if (unlikely(lock_inode))
+ inode_unlock(inode);
+
/* If the page is not already dirty, ll_tiny_write_begin returns
* -ENODATA. We continue on to normal write.
*/
@@ -1037,13 +1037,13 @@ static int vvp_io_write_start(const struct lu_env *env,
* consistency, proper locking to protect against writes,
* trucates, etc. is handled in the higher layers of lustre.
*/
- bool lock_node = !IS_NOSEC(inode);
+ lock_inode = !IS_NOSEC(inode);
- if (lock_node)
+ if (unlikely(lock_inode))
inode_lock(inode);
result = __generic_file_write_iter(vio->vui_iocb,
vio->vui_iter);
- if (lock_node)
+ if (unlikely(lock_inode))
inode_unlock(inode);
if (result > 0 || result == -EIOCBQUEUED)