From: Andi Kleen <andi@firstfloor.org>
To: viro@zeniv.linux.org.uk
Cc: hch@infradead.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
tytso@mit.edu
Subject: [PATCH 4/5] EXT4: Replace cut'n'pasted llseek code with generic_file_llseek_size
Date: Thu, 16 Jun 2011 14:07:21 -0700 [thread overview]
Message-ID: <1308258442-19804-4-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1308258442-19804-1-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
This gives ext4 the benefits of unlocked llseek.
Cc: tytso@mit.edu
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
fs/ext4/file.c | 26 +-------------------------
1 files changed, 1 insertions(+), 25 deletions(-)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 2c09723..ce40447 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -224,32 +224,8 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int origin)
maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
else
maxbytes = inode->i_sb->s_maxbytes;
- mutex_lock(&inode->i_mutex);
- switch (origin) {
- case SEEK_END:
- offset += inode->i_size;
- break;
- case SEEK_CUR:
- if (offset == 0) {
- mutex_unlock(&inode->i_mutex);
- return file->f_pos;
- }
- offset += file->f_pos;
- break;
- }
-
- if (offset < 0 || offset > maxbytes) {
- mutex_unlock(&inode->i_mutex);
- return -EINVAL;
- }
-
- if (offset != file->f_pos) {
- file->f_pos = offset;
- file->f_version = 0;
- }
- mutex_unlock(&inode->i_mutex);
- return offset;
+ return generic_file_llseek_size(file, offset, origin, maxbytes);
}
const struct file_operations ext4_file_operations = {
--
1.7.4.4
next prev parent reply other threads:[~2011-06-16 21:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 21:07 [PATCH 1/5] VFS: Do (nearly) lockless generic_file_llseek Andi Kleen
2011-06-16 21:07 ` [PATCH 2/5] VFS: Use f_lock for SEEK_SET Andi Kleen
2011-06-16 21:07 ` [PATCH 3/5] VFS: Add generic_file_llseek_size Andi Kleen
2011-06-16 21:07 ` Andi Kleen [this message]
2011-06-16 21:07 ` [PATCH 5/5] NFS: Drop unnecessary locking in llseek Andi Kleen
2011-06-17 12:40 ` [PATCH 1/5] VFS: Do (nearly) lockless generic_file_llseek Arnd Bergmann
2011-06-17 17:42 ` Andi Kleen
2011-06-17 21:18 ` Arnd Bergmann
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=1308258442-19804-4-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).