* [PATCH 1/2] wire up ->open for directories
@ 2008-10-26 20:34 Christoph Hellwig
2008-10-27 1:20 ` Dave Chinner
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2008-10-26 20:34 UTC (permalink / raw)
To: xfs
[-- Attachment #1: xfs-wire-up-open --]
[-- Type: text/plain, Size: 3646 bytes --]
Currently there's no ->open method set for directories on XFS. That
means we don't perform any check for opening too large directories
without O_LARGEFILE, we don't check for shut down filesystems, and we
don't actually do the readahead for the first block in the directory.
Instead of just setting the directories open routine to xfs_file_open
we merge the shutdown check directly into xfs_file_open and create
a new xfs_dir_open that first calls xfs_file_open and then performs
the readahead for block 0.
(First sent on September 29th)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_file.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_file.c 2008-09-09 17:35:49.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_file.c 2008-09-09 17:44:13.000000000 +0200
@@ -38,6 +38,7 @@
#include "xfs_rw.h"
#include "xfs_ioctl32.h"
#include "xfs_vnodeops.h"
+#include "xfs_da_btree.h"
#include <linux/dcache.h>
#include <linux/smp_lock.h>
@@ -172,11 +173,37 @@ xfs_file_splice_write_invis(
STATIC int
xfs_file_open(
struct inode *inode,
- struct file *filp)
+ struct file *file)
{
- if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
+ if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EFBIG;
- return -xfs_open(XFS_I(inode));
+ if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb)))
+ return -EIO;
+ return 0;
+}
+
+STATIC int
+xfs_dir_open(
+ struct inode *inode,
+ struct file *file)
+{
+ struct xfs_inode *ip = XFS_I(inode);
+ int mode;
+ int error;
+
+ error = xfs_file_open(inode, file);
+ if (error)
+ return error;
+
+ /*
+ * If there are any blocks, read-ahead block 0 as we're almost
+ * certain to have the next operation be a read there.
+ */
+ mode = xfs_ilock_map_shared(ip);
+ if (ip->i_d.di_nextents > 0)
+ xfs_da_reada_buf(NULL, ip, 0, XFS_DATA_FORK);
+ xfs_iunlock(ip, mode);
+ return 0;
}
STATIC int
@@ -533,6 +560,7 @@ const struct file_operations xfs_invis_f
const struct file_operations xfs_dir_file_operations = {
+ .open = xfs_dir_open,
.read = generic_read_dir,
.readdir = xfs_file_readdir,
.unlocked_ioctl = xfs_file_ioctl,
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_vnodeops.c 2008-09-09 17:35:49.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_vnodeops.c 2008-09-09 17:35:59.000000000 +0200
@@ -54,28 +54,6 @@
#include "xfs_vnodeops.h"
int
-xfs_open(
- xfs_inode_t *ip)
-{
- int mode;
-
- if (XFS_FORCED_SHUTDOWN(ip->i_mount))
- return XFS_ERROR(EIO);
-
- /*
- * If it's a directory with any blocks, read-ahead block 0
- * as we're almost certain to have the next operation be a read there.
- */
- if (S_ISDIR(ip->i_d.di_mode) && ip->i_d.di_nextents > 0) {
- mode = xfs_ilock_map_shared(ip);
- if (ip->i_d.di_nextents > 0)
- (void)xfs_da_reada_buf(NULL, ip, 0, XFS_DATA_FORK);
- xfs_iunlock(ip, mode);
- }
- return 0;
-}
-
-int
xfs_setattr(
struct xfs_inode *ip,
struct iattr *iattr,
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_vnodeops.h 2008-09-09 17:35:42.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_vnodeops.h 2008-09-09 17:35:45.000000000 +0200
@@ -14,7 +14,6 @@ struct xfs_inode;
struct xfs_iomap;
-int xfs_open(struct xfs_inode *ip);
int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
struct cred *credp);
#define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] wire up ->open for directories
2008-10-26 20:34 Christoph Hellwig
@ 2008-10-27 1:20 ` Dave Chinner
0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2008-10-27 1:20 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Sun, Oct 26, 2008 at 04:34:37PM -0400, Christoph Hellwig wrote:
> Currently there's no ->open method set for directories on XFS. That
> means we don't perform any check for opening too large directories
> without O_LARGEFILE, we don't check for shut down filesystems, and we
> don't actually do the readahead for the first block in the directory.
>
> Instead of just setting the directories open routine to xfs_file_open
> we merge the shutdown check directly into xfs_file_open and create
> a new xfs_dir_open that first calls xfs_file_open and then performs
> the readahead for block 0.
Looks good to me.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] wire up ->open for directories
@ 2008-10-27 13:30 Christoph Hellwig
2008-10-27 23:36 ` Dave Chinner
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2008-10-27 13:30 UTC (permalink / raw)
To: xfs
[-- Attachment #1: xfs-wire-up-open --]
[-- Type: text/plain, Size: 3646 bytes --]
Currently there's no ->open method set for directories on XFS. That
means we don't perform any check for opening too large directories
without O_LARGEFILE, we don't check for shut down filesystems, and we
don't actually do the readahead for the first block in the directory.
Instead of just setting the directories open routine to xfs_file_open
we merge the shutdown check directly into xfs_file_open and create
a new xfs_dir_open that first calls xfs_file_open and then performs
the readahead for block 0.
(First sent on September 29th)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_file.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_file.c 2008-09-09 17:35:49.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_file.c 2008-09-09 17:44:13.000000000 +0200
@@ -38,6 +38,7 @@
#include "xfs_rw.h"
#include "xfs_ioctl32.h"
#include "xfs_vnodeops.h"
+#include "xfs_da_btree.h"
#include <linux/dcache.h>
#include <linux/smp_lock.h>
@@ -172,11 +173,37 @@ xfs_file_splice_write_invis(
STATIC int
xfs_file_open(
struct inode *inode,
- struct file *filp)
+ struct file *file)
{
- if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
+ if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EFBIG;
- return -xfs_open(XFS_I(inode));
+ if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb)))
+ return -EIO;
+ return 0;
+}
+
+STATIC int
+xfs_dir_open(
+ struct inode *inode,
+ struct file *file)
+{
+ struct xfs_inode *ip = XFS_I(inode);
+ int mode;
+ int error;
+
+ error = xfs_file_open(inode, file);
+ if (error)
+ return error;
+
+ /*
+ * If there are any blocks, read-ahead block 0 as we're almost
+ * certain to have the next operation be a read there.
+ */
+ mode = xfs_ilock_map_shared(ip);
+ if (ip->i_d.di_nextents > 0)
+ xfs_da_reada_buf(NULL, ip, 0, XFS_DATA_FORK);
+ xfs_iunlock(ip, mode);
+ return 0;
}
STATIC int
@@ -533,6 +560,7 @@ const struct file_operations xfs_invis_f
const struct file_operations xfs_dir_file_operations = {
+ .open = xfs_dir_open,
.read = generic_read_dir,
.readdir = xfs_file_readdir,
.unlocked_ioctl = xfs_file_ioctl,
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_vnodeops.c 2008-09-09 17:35:49.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_vnodeops.c 2008-09-09 17:35:59.000000000 +0200
@@ -54,28 +54,6 @@
#include "xfs_vnodeops.h"
int
-xfs_open(
- xfs_inode_t *ip)
-{
- int mode;
-
- if (XFS_FORCED_SHUTDOWN(ip->i_mount))
- return XFS_ERROR(EIO);
-
- /*
- * If it's a directory with any blocks, read-ahead block 0
- * as we're almost certain to have the next operation be a read there.
- */
- if (S_ISDIR(ip->i_d.di_mode) && ip->i_d.di_nextents > 0) {
- mode = xfs_ilock_map_shared(ip);
- if (ip->i_d.di_nextents > 0)
- (void)xfs_da_reada_buf(NULL, ip, 0, XFS_DATA_FORK);
- xfs_iunlock(ip, mode);
- }
- return 0;
-}
-
-int
xfs_setattr(
struct xfs_inode *ip,
struct iattr *iattr,
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_vnodeops.h 2008-09-09 17:35:42.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_vnodeops.h 2008-09-09 17:35:45.000000000 +0200
@@ -14,7 +14,6 @@ struct xfs_inode;
struct xfs_iomap;
-int xfs_open(struct xfs_inode *ip);
int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
struct cred *credp);
#define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] wire up ->open for directories
2008-10-27 13:30 [PATCH 1/2] wire up ->open for directories Christoph Hellwig
@ 2008-10-27 23:36 ` Dave Chinner
0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2008-10-27 23:36 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Mon, Oct 27, 2008 at 09:30:13AM -0400, Christoph Hellwig wrote:
> Currently there's no ->open method set for directories on XFS. That
> means we don't perform any check for opening too large directories
> without O_LARGEFILE, we don't check for shut down filesystems, and we
> don't actually do the readahead for the first block in the directory.
>
> Instead of just setting the directories open routine to xfs_file_open
> we merge the shutdown check directly into xfs_file_open and create
> a new xfs_dir_open that first calls xfs_file_open and then performs
> the readahead for block 0.
>
> (First sent on September 29th)
>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by; Dave Chinner <david@fromorbit.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-27 23:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-27 13:30 [PATCH 1/2] wire up ->open for directories Christoph Hellwig
2008-10-27 23:36 ` Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2008-10-26 20:34 Christoph Hellwig
2008-10-27 1:20 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox