From 026a392e61cff0607c6787a30ab22a61b169c02e Mon Sep 17 00:00:00 2001 From: green Date: Thu, 6 May 2004 18:36:26 +0000 Subject: [PATCH] Another update to HEAD (with b_smfs), killed lookup_create() duplication in lvfs/, exported lookup_create in vfs_intent* patches instead. --- lustre/include/linux/lustre_fsfilt.h | 329 ++++++++++++++++++++++++++--------- 1 file changed, 249 insertions(+), 80 deletions(-) diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 72f3817..ae8b544 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -1,7 +1,7 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (C) 2001 Cluster File Systems, Inc. + * Copyright (C) 2001-2004 Cluster File Systems, Inc. * * This file is part of Lustre, http://www.lustre.org. * @@ -28,6 +28,7 @@ #ifdef __KERNEL__ #include +#include #include typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd, @@ -58,10 +59,23 @@ struct fsfilt_operations { int (* fs_set_md)(struct inode *inode, void *handle, void *md, int size); int (* fs_get_md)(struct inode *inode, void *md, int size); + + /* this method is needed to make IO operation fsfilt nature depend. */ +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) + int (* fs_send_bio)(struct inode *inode, struct bio *bio); +#else + int (* fs_send_bio)(struct inode *inode, struct kiobuf *bio); +#endif + + /* methods for getting page from backing fs and putting page there + * during IO. Used on OST. */ + int (* fs_putpage)(struct inode *inode, struct page *page); + struct page *(* fs_getpage)(struct inode *inode, long int index); + ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count, loff_t *offset); - int (* fs_add_journal_cb)(struct obd_device *obd, __u64 last_rcvd, - void *handle, fsfilt_cb_t cb_func, + int (* fs_add_journal_cb)(struct obd_device *obd, struct super_block *sb, + __u64 last_rcvd, void *handle, fsfilt_cb_t cb_func, void *cb_data); int (* fs_statfs)(struct super_block *sb, struct obd_statfs *osfs); int (* fs_sync)(struct super_block *sb); @@ -74,6 +88,12 @@ struct fsfilt_operations { int force_sync); int (* fs_read_record)(struct file *, void *, int size, loff_t *); int (* fs_setup)(struct super_block *sb); + + int (* fs_set_xattr)(struct inode *inode, void *handle, char *name, + void *buffer, int buffer_size); + int (* fs_get_xattr)(struct inode *inode, char *name, + void *buffer, int buffer_size); + int (* fs_get_op_len)(int, struct fsfilt_objinfo *, int); }; @@ -92,15 +112,46 @@ extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops); #define FSFILT_OP_SETATTR 8 #define FSFILT_OP_LINK 9 #define FSFILT_OP_CANCEL_UNLINK 10 - -static inline void *fsfilt_start_log(struct obd_device *obd, - struct inode *inode, int op, - struct obd_trans_info *oti, int logs) +#define FSFILT_OP_NOOP 15 + +/* XXX BUG 3188 -- must return to one set of opcodes */ +#define KML_UNLINK 0x11 +#define KML_RMDIR 0x12 +#define KML_RENAME 0x13 +#define KML_CREATE 0x14 +#define KML_MKDIR 0x15 +#define KML_SYMLINK 0x16 +#define KML_MKNOD 0x17 +#define KML_LINK 0x19 + +#define CACHE_UNLINK 0x21 +#define CACHE_RMDIR 0x22 +#define CACHE_RENAME 0x23 +#define CACHE_CREATE 0x24 +#define CACHE_MKDIR 0x25 +#define CACHE_SYMLINK 0x26 +#define CACHE_MKNOD 0x27 +#define CACHE_LINK 0x29 +#define CACHE_NOOP 0x2f + +#define KML_CACHE_UNLINK 0x31 +#define KML_CACHE_RMDIR 0x32 +#define KML_CACHE_RENAME 0x33 +#define KML_CACHE_CREATE 0x34 +#define KML_CACHE_MKDIR 0x35 +#define KML_CACHE_SYMLINK 0x36 +#define KML_CACHE_MKNOD 0x37 +#define KML_CACHE_LINK 0x39 +#define KML_CACHE_NOOP 0x3f + +static inline void * +fsfilt_start_ops(struct fsfilt_operations *ops, struct inode *inode, + int op, struct obd_trans_info *oti, int logs) { unsigned long now = jiffies; void *parent_handle = oti ? oti->oti_handle : NULL; - void *handle = obd->obd_fsops->fs_start(inode, op, parent_handle, logs); - CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle); + void *handle = ops->fs_start(inode, op, parent_handle, logs); + CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle); if (oti != NULL) { if (parent_handle == NULL) { @@ -116,17 +167,60 @@ static inline void *fsfilt_start_log(struct obd_device *obd, return handle; } -static inline void *fsfilt_start(struct obd_device *obd, struct inode *inode, - int op, struct obd_trans_info *oti) +static inline void * +fsfilt_start_log(struct obd_device *obd, struct inode *inode, + int op, struct obd_trans_info *oti, int logs) +{ + return fsfilt_start_ops(obd->obd_fsops, inode, op, oti, logs); +} + +static inline void * +fsfilt_start(struct obd_device *obd, struct inode *inode, + int op, struct obd_trans_info *oti) +{ + return fsfilt_start_ops(obd->obd_fsops, inode, op, oti, 0); +} + +static inline void * +llog_fsfilt_start(struct llog_ctxt *ctxt, struct inode *inode, + int op, struct obd_trans_info *oti) +{ + return fsfilt_start_ops(ctxt->loc_fsops, inode, op, oti, 1); +} + +static inline int +fsfilt_commit_ops(struct fsfilt_operations *ops, struct inode *inode, + void *handle, int force_sync) +{ + unsigned long now = jiffies; + int rc = ops->fs_commit(inode, handle, force_sync); + CDEBUG(D_HA, "committing handle %p\n", handle); + + if (time_after(jiffies, now + 15 * HZ)) + CERROR("long journal start time %lus\n", (jiffies - now) / HZ); + + return rc; +} + +static inline int +fsfilt_commit(struct obd_device *obd, struct inode *inode, + void *handle, int force_sync) +{ + return fsfilt_commit_ops(obd->obd_fsops, inode, handle, force_sync); +} + +static inline int +llog_fsfilt_commit(struct llog_ctxt *ctxt, struct inode *inode, + void *handle, int force_sync) { - return fsfilt_start_log(obd, inode, op, oti, 0); + return fsfilt_commit_ops(ctxt->loc_fsops, inode, handle, force_sync); } -static inline void *fsfilt_brw_start_log(struct obd_device *obd, - int objcount, - struct fsfilt_objinfo *fso, - int niocount, struct niobuf_local *nb, - struct obd_trans_info *oti, int logs) +static inline void * +fsfilt_brw_start_log(struct obd_device *obd, int objcount, + struct fsfilt_objinfo *fso, int niocount, + struct niobuf_local *nb, struct obd_trans_info *oti, + int logs) { unsigned long now = jiffies; void *parent_handle = oti ? oti->oti_handle : NULL; @@ -149,30 +243,17 @@ static inline void *fsfilt_brw_start_log(struct obd_device *obd, return handle; } -static inline void *fsfilt_brw_start(struct obd_device *obd, int objcount, - struct fsfilt_objinfo *fso, int niocount, - struct niobuf_local *nb, - struct obd_trans_info *oti) +static inline void * +fsfilt_brw_start(struct obd_device *obd, int objcount, + struct fsfilt_objinfo *fso, int niocount, + struct niobuf_local *nb, struct obd_trans_info *oti) { return fsfilt_brw_start_log(obd, objcount, fso, niocount, nb, oti, 0); } -static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, - void *handle, int force_sync) -{ - unsigned long now = jiffies; - int rc = obd->obd_fsops->fs_commit(inode, handle, force_sync); - CDEBUG(D_INFO, "committing handle %p\n", handle); - - if (time_after(jiffies, now + 15 * HZ)) - CERROR("long journal start time %lus\n", (jiffies - now) / HZ); - - return rc; -} - -static inline int fsfilt_commit_async(struct obd_device *obd, - struct inode *inode, void *handle, - void **wait_handle) +static inline int +fsfilt_commit_async(struct obd_device *obd, struct inode *inode, + void *handle, void **wait_handle) { unsigned long now = jiffies; int rc = obd->obd_fsops->fs_commit_async(inode, handle, wait_handle); @@ -184,8 +265,8 @@ static inline int fsfilt_commit_async(struct obd_device *obd, return rc; } -static inline int fsfilt_commit_wait(struct obd_device *obd, - struct inode *inode, void *handle) +static inline int +fsfilt_commit_wait(struct obd_device *obd, struct inode *inode, void *handle) { unsigned long now = jiffies; int rc = obd->obd_fsops->fs_commit_wait(inode, handle); @@ -195,8 +276,9 @@ static inline int fsfilt_commit_wait(struct obd_device *obd, return rc; } -static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry, - void *handle, struct iattr *iattr,int do_trunc) +static inline int +fsfilt_setattr(struct obd_device *obd, struct dentry *dentry, + void *handle, struct iattr *iattr, int do_trunc) { unsigned long now = jiffies; int rc; @@ -206,43 +288,120 @@ static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry, return rc; } -static inline int fsfilt_iocontrol(struct obd_device *obd, struct inode *inode, - struct file *file, unsigned int cmd, - unsigned long arg) +static inline int +fsfilt_iocontrol(struct obd_device *obd, struct inode *inode, + struct file *file, unsigned int cmd, + unsigned long arg) { return obd->obd_fsops->fs_iocontrol(inode, file, cmd, arg); } -static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode, - void *handle, void *md, int size) +static inline int fsfilt_setup(struct obd_device *obd, + struct super_block *fs) +{ + if (obd->obd_fsops->fs_setup) + return obd->obd_fsops->fs_setup(fs); + + return 0; +} + +static inline int +fsfilt_set_md(struct obd_device *obd, struct inode *inode, + void *handle, void *md, int size) { return obd->obd_fsops->fs_set_md(inode, handle, md, size); } -static inline int fsfilt_get_md(struct obd_device *obd, struct inode *inode, - void *md, int size) +static inline int +fsfilt_get_md(struct obd_device *obd, struct inode *inode, + void *md, int size) { return obd->obd_fsops->fs_get_md(inode, md, size); } -static inline ssize_t fsfilt_readpage(struct obd_device *obd, - struct file *file, char *buf, - size_t count, loff_t *offset) +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) +static inline int +fsfilt_send_bio(struct obd_device *obd, struct inode *inode, + struct bio *bio) +#else +static inline int +fsfilt_send_bio(struct obd_device *obd, struct inode *inode, + struct kiobuf *bio) +#endif +{ + return obd->obd_fsops->fs_send_bio(inode, bio); +} + +static inline int +fsfilt_putpage(struct obd_device *obd, struct inode *inode, + struct page *page) +{ + int rc = 0; + struct filter_obd *filter; + unsigned long now = jiffies; + + LASSERT(obd != NULL); + LASSERT(inode != NULL); + LASSERT(page != NULL); + + filter = &obd->u.filter; + + if (!obd->obd_fsops->fs_putpage) + return -ENOSYS; + + CDEBUG(D_INFO, "putpage %lx\n", page->index); + + rc = obd->obd_fsops->fs_putpage(inode, page); + + if (time_after(jiffies, now + 15 * HZ)) + CERROR("long putpage time %lus\n", (jiffies - now) / HZ); + + return rc; +} + +static inline struct page * +fsfilt_getpage(struct obd_device *obd, struct inode *inode, + unsigned long index) +{ + struct page *page; + unsigned long now = jiffies; + + LASSERT(obd != NULL); + LASSERT(inode != NULL); + + if (!obd->obd_fsops->fs_getpage) + return ERR_PTR(-ENOSYS); + + CDEBUG(D_INFO, "getpage %lx\n", index); + + page = obd->obd_fsops->fs_getpage(inode, index); + + if (time_after(jiffies, now + 15 * HZ)) + CERROR("long getpage time %lus\n", (jiffies - now) / HZ); + + return page; +} + +static inline ssize_t +fsfilt_readpage(struct obd_device *obd, struct file *file, char *buf, + size_t count, loff_t *offset) { return obd->obd_fsops->fs_readpage(file, buf, count, offset); } -static inline int fsfilt_add_journal_cb(struct obd_device *obd, __u64 last_rcvd, - void *handle, fsfilt_cb_t cb_func, - void *cb_data) +static inline int +fsfilt_add_journal_cb(struct obd_device *obd, struct super_block *sb, + __u64 last_rcvd, void *handle, fsfilt_cb_t cb_func, + void *cb_data) { - return obd->obd_fsops->fs_add_journal_cb(obd, last_rcvd, - handle, cb_func, cb_data); + return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_rcvd, handle, + cb_func, cb_data); } /* very similar to obd_statfs(), but caller already holds obd_osfs_lock */ -static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *sb, - unsigned long max_age) +static inline int +fsfilt_statfs(struct obd_device *obd, struct super_block *sb, + unsigned long max_age) { int rc = 0; @@ -258,48 +417,58 @@ static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *sb, return rc; } -static inline int fsfilt_sync(struct obd_device *obd, struct super_block *sb) +static inline int +fsfilt_sync(struct obd_device *obd, struct super_block *sb) { return obd->obd_fsops->fs_sync(sb); } -static inline int fsfilt_map_inode_page(struct obd_device *obd, - struct inode *inode, struct page *page, - unsigned long *blocks, int *created, - int create) +static inline int +fsfilt_map_inode_page(struct obd_device *obd, struct inode *inode, + struct page *page, unsigned long *blocks, + int *created, int create) { - return obd->obd_fsops->fs_map_inode_page(inode, page, blocks, created, - create); + return obd->obd_fsops->fs_map_inode_page(inode, page, blocks, + created, create); } -static inline int fs_prep_san_write(struct obd_device *obd, - struct inode *inode, - long *blocks, - int nblocks, - loff_t newsize) +static inline int +fs_prep_san_write(struct obd_device *obd, struct inode *inode, + long *blocks, int nblocks, loff_t newsize) { return obd->obd_fsops->fs_prep_san_write(inode, blocks, nblocks, newsize); } -static inline int fsfilt_read_record(struct obd_device *obd, struct file *file, - void *buf, loff_t size, loff_t *offs) +static inline int +fsfilt_read_record(struct obd_device *obd, struct file *file, + void *buf, loff_t size, loff_t *offs) { return obd->obd_fsops->fs_read_record(file, buf, size, offs); } -static inline int fsfilt_write_record(struct obd_device *obd, struct file *file, - void *buf, loff_t size, loff_t *offs, - int force_sync) +static inline int +fsfilt_write_record(struct obd_device *obd, struct file *file, + void *buf, loff_t size, loff_t *offs, int force_sync) { - return obd->obd_fsops->fs_write_record(file, buf, size,offs,force_sync); + return obd->obd_fsops->fs_write_record(file, buf, size, offs, + force_sync); } -static inline int fsfilt_setup(struct obd_device *obd, struct super_block *fs) +static inline int +llog_fsfilt_write_record(struct llog_ctxt *ctxt, struct file *file, + void *buf, loff_t size, loff_t *offs, + int force_sync) { - if (obd->obd_fsops->fs_setup) - return obd->obd_fsops->fs_setup(fs); - return 0; + return ctxt->loc_fsops->fs_write_record(file, buf, size, offs, + force_sync); +} + +static inline int +llog_fsfilt_read_record(struct llog_ctxt *ctxt, struct file *file, + void *buf, loff_t size, loff_t *offs) +{ + return ctxt->loc_fsops->fs_read_record(file, buf, size, offs); } #endif /* __KERNEL__ */ -- 1.8.3.1