diff options
Diffstat (limited to 'fs/orangefs')
-rw-r--r-- | fs/orangefs/devorangefs-req.c | 72 | ||||
-rw-r--r-- | fs/orangefs/file.c | 127 | ||||
-rw-r--r-- | fs/orangefs/inode.c | 61 | ||||
-rw-r--r-- | fs/orangefs/namei.c | 80 | ||||
-rw-r--r-- | fs/orangefs/orangefs-bufmap.c | 24 | ||||
-rw-r--r-- | fs/orangefs/orangefs-debug.h | 6 | ||||
-rw-r--r-- | fs/orangefs/orangefs-debugfs.c | 2 | ||||
-rw-r--r-- | fs/orangefs/orangefs-kernel.h | 81 | ||||
-rw-r--r-- | fs/orangefs/orangefs-utils.c | 30 | ||||
-rw-r--r-- | fs/orangefs/protocol.h | 47 | ||||
-rw-r--r-- | fs/orangefs/super.c | 18 | ||||
-rw-r--r-- | fs/orangefs/waitqueue.c | 14 |
12 files changed, 184 insertions, 378 deletions
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c index b03057afac2a..74b37cbbd5d4 100644 --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c @@ -281,14 +281,17 @@ restart: ret = copy_to_user(buf, &proto_ver, sizeof(__s32)); if (ret != 0) goto error; - ret = copy_to_user(buf+sizeof(__s32), &magic, sizeof(__s32)); + ret = copy_to_user(buf + sizeof(__s32), &magic, sizeof(__s32)); if (ret != 0) goto error; - ret = copy_to_user(buf+2 * sizeof(__s32), &cur_op->tag, sizeof(__u64)); + ret = copy_to_user(buf + 2 * sizeof(__s32), + &cur_op->tag, + sizeof(__u64)); if (ret != 0) goto error; - ret = copy_to_user(buf+2*sizeof(__s32)+sizeof(__u64), &cur_op->upcall, - sizeof(struct orangefs_upcall_s)); + ret = copy_to_user(buf + 2 * sizeof(__s32) + sizeof(__u64), + &cur_op->upcall, + sizeof(struct orangefs_upcall_s)); if (ret != 0) goto error; @@ -381,7 +384,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, (unsigned int) MAX_DEV_REQ_DOWNSIZE); return -EFAULT; } - + if (!copy_from_iter_full(&head, head_size, iter)) { gossip_err("%s: failed to copy head.\n", __func__); return -EFAULT; @@ -426,7 +429,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, goto wakeup; /* - * We've successfully peeled off the head and the downcall. + * We've successfully peeled off the head and the downcall. * Something has gone awry if total doesn't equal the * sum of head_size, downcall_size and trailer_size. */ @@ -463,11 +466,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, if (op->downcall.type != ORANGEFS_VFS_OP_READDIR) goto wakeup; - op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size); + op->downcall.trailer_buf = vzalloc(op->downcall.trailer_size); if (!op->downcall.trailer_buf) goto Enomem; - memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size); if (!copy_from_iter_full(op->downcall.trailer_buf, op->downcall.trailer_size, iter)) { gossip_err("%s: failed to copy trailer.\n", __func__); @@ -478,7 +480,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, wakeup: /* * Return to vfs waitqueue, and back to service_operation - * through wait_for_matching_downcall. + * through wait_for_matching_downcall. */ spin_lock(&op->lock); if (unlikely(op_is_cancel(op))) { @@ -779,9 +781,35 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd, #endif /* CONFIG_COMPAT is in .config */ +static __poll_t orangefs_devreq_poll(struct file *file, + struct poll_table_struct *poll_table) +{ + __poll_t poll_revent_mask = 0; + + poll_wait(file, &orangefs_request_list_waitq, poll_table); + + if (!list_empty(&orangefs_request_list)) + poll_revent_mask |= EPOLLIN; + return poll_revent_mask; +} + /* the assigned character device major number */ static int orangefs_dev_major; +static const struct file_operations orangefs_devreq_file_operations = { + .owner = THIS_MODULE, + .read = orangefs_devreq_read, + .write_iter = orangefs_devreq_write_iter, + .open = orangefs_devreq_open, + .release = orangefs_devreq_release, + .unlocked_ioctl = orangefs_devreq_ioctl, + +#ifdef CONFIG_COMPAT /* CONFIG_COMPAT is in .config */ + .compat_ioctl = orangefs_devreq_compat_ioctl, +#endif + .poll = orangefs_devreq_poll +}; + /* * Initialize orangefs device specific state: * Must be called at module load time only @@ -814,29 +842,3 @@ void orangefs_dev_cleanup(void) "*** /dev/%s character device unregistered ***\n", ORANGEFS_REQDEVICE_NAME); } - -static __poll_t orangefs_devreq_poll(struct file *file, - struct poll_table_struct *poll_table) -{ - __poll_t poll_revent_mask = 0; - - poll_wait(file, &orangefs_request_list_waitq, poll_table); - - if (!list_empty(&orangefs_request_list)) - poll_revent_mask |= EPOLLIN; - return poll_revent_mask; -} - -const struct file_operations orangefs_devreq_file_operations = { - .owner = THIS_MODULE, - .read = orangefs_devreq_read, - .write_iter = orangefs_devreq_write_iter, - .open = orangefs_devreq_open, - .release = orangefs_devreq_release, - .unlocked_ioctl = orangefs_devreq_ioctl, - -#ifdef CONFIG_COMPAT /* CONFIG_COMPAT is in .config */ - .compat_ioctl = orangefs_devreq_compat_ioctl, -#endif - .poll = orangefs_devreq_poll -}; diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index 0d228cd087e6..db0b52187cbc 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -42,70 +42,6 @@ static int flush_racache(struct inode *inode) } /* - * Copy to client-core's address space from the buffers specified - * by the iovec upto total_size bytes. - * NOTE: the iovector can either contain addresses which - * can futher be kernel-space or user-space addresses. - * or it can pointers to struct page's - */ -static int precopy_buffers(int buffer_index, - struct iov_iter *iter, - size_t total_size) -{ - int ret = 0; - /* - * copy data from application/kernel by pulling it out - * of the iovec. - */ - - - if (total_size) { - ret = orangefs_bufmap_copy_from_iovec(iter, - buffer_index, - total_size); - if (ret < 0) - gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n", - __func__, - (long)ret); - } - - if (ret < 0) - gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n", - __func__, - (long)ret); - return ret; -} - -/* - * Copy from client-core's address space to the buffers specified - * by the iovec upto total_size bytes. - * NOTE: the iovector can either contain addresses which - * can futher be kernel-space or user-space addresses. - * or it can pointers to struct page's - */ -static int postcopy_buffers(int buffer_index, - struct iov_iter *iter, - size_t total_size) -{ - int ret = 0; - /* - * copy data to application/kernel by pushing it out to - * the iovec. NOTE; target buffers can be addresses or - * struct page pointers. - */ - if (total_size) { - ret = orangefs_bufmap_copy_to_iovec(iter, - buffer_index, - total_size); - if (ret < 0) - gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n", - __func__, - (long)ret); - } - return ret; -} - -/* * Post and wait for the I/O upcall to finish */ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, @@ -157,14 +93,15 @@ populate_shared_memory: total_size); /* * Stage 1: copy the buffers into client-core's address space - * precopy_buffers only pertains to writes. */ - if (type == ORANGEFS_IO_WRITE) { - ret = precopy_buffers(buffer_index, - iter, - total_size); - if (ret < 0) + if (type == ORANGEFS_IO_WRITE && total_size) { + ret = orangefs_bufmap_copy_from_iovec(iter, buffer_index, + total_size); + if (ret < 0) { + gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n", + __func__, (long)ret); goto out; + } } gossip_debug(GOSSIP_FILE_DEBUG, @@ -225,7 +162,7 @@ populate_shared_memory: else ret = 0; break; - /* + /* * If the op was in progress when the interrupt * occurred, then the client-core was able to * trigger the write. @@ -260,14 +197,20 @@ populate_shared_memory: /* * Stage 3: Post copy buffers from client-core's address space - * postcopy_buffers only pertains to reads. */ - if (type == ORANGEFS_IO_READ) { - ret = postcopy_buffers(buffer_index, - iter, - new_op->downcall.resp.io.amt_complete); - if (ret < 0) + if (type == ORANGEFS_IO_READ && new_op->downcall.resp.io.amt_complete) { + /* + * NOTE: the iovector can either contain addresses which + * can futher be kernel-space or user-space addresses. + * or it can pointers to struct page's + */ + ret = orangefs_bufmap_copy_to_iovec(iter, buffer_index, + new_op->downcall.resp.io.amt_complete); + if (ret < 0) { + gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n", + __func__, (long)ret); goto out; + } } gossip_debug(GOSSIP_FILE_DEBUG, "%s(%pU): Amount %s, returned by the sys-io call:%d\n", @@ -585,6 +528,28 @@ static long orangefs_ioctl(struct file *file, unsigned int cmd, unsigned long ar return ret; } +static int orangefs_fault(struct vm_fault *vmf) +{ + struct file *file = vmf->vma->vm_file; + int rc; + rc = orangefs_inode_getattr(file->f_mapping->host, 0, 1, + STATX_SIZE); + if (rc == -ESTALE) + rc = -EIO; + if (rc) { + gossip_err("%s: orangefs_inode_getattr failed, " + "rc:%d:.\n", __func__, rc); + return rc; + } + return filemap_fault(vmf); +} + +static const struct vm_operations_struct orangefs_file_vm_ops = { + .fault = orangefs_fault, + .map_pages = filemap_map_pages, + .page_mkwrite = filemap_page_mkwrite, +}; + /* * Memory map a region of a file. */ @@ -596,12 +561,16 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma) (char *)file->f_path.dentry->d_name.name : (char *)"Unknown")); + if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) + return -EINVAL; + /* set the sequential readahead hint */ vma->vm_flags |= VM_SEQ_READ; vma->vm_flags &= ~VM_RAND_READ; - /* Use readonly mmap since we cannot support writable maps. */ - return generic_file_readonly_mmap(file, vma); + file_accessed(file); + vma->vm_ops = &orangefs_file_vm_ops; + return 0; } #define mapping_nrpages(idata) ((idata)->nrpages) diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index fe1d705ad91f..d6db252e6200 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -20,8 +20,8 @@ static int read_one_page(struct page *page) int max_block; ssize_t bytes_read = 0; struct inode *inode = page->mapping->host; - const __u32 blocksize = PAGE_SIZE; /* inode->i_blksize */ - const __u32 blockbits = PAGE_SHIFT; /* inode->i_blkbits */ + const __u32 blocksize = PAGE_SIZE; + const __u32 blockbits = PAGE_SHIFT; struct iov_iter to; struct bio_vec bv = {.bv_page = page, .bv_len = PAGE_SIZE}; @@ -138,7 +138,7 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, } /** ORANGEFS2 implementation of address space operations */ -const struct address_space_operations orangefs_address_operations = { +static const struct address_space_operations orangefs_address_operations = { .readpage = orangefs_readpage, .readpages = orangefs_readpages, .invalidatepage = orangefs_invalidatepage, @@ -181,16 +181,15 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) new_op->upcall.req.truncate.refn = orangefs_inode->refn; new_op->upcall.req.truncate.size = (__s64) iattr->ia_size; - ret = service_operation(new_op, __func__, - get_interruptible_flag(inode)); + ret = service_operation(new_op, + __func__, + get_interruptible_flag(inode)); /* * the truncate has no downcall members to retrieve, but * the status value tells us if it went through ok or not */ - gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs: orangefs_truncate got return value of %d\n", - ret); + gossip_debug(GOSSIP_INODE_DEBUG, "%s: ret:%d:\n", __func__, ret); op_release(new_op); @@ -212,8 +211,9 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr) struct inode *inode = dentry->d_inode; gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_setattr: called on %pd\n", - dentry); + "%s: called on %pd\n", + __func__, + dentry); ret = setattr_prepare(dentry, iattr); if (ret) @@ -230,15 +230,16 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr) ret = orangefs_inode_setattr(inode, iattr); gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_setattr: inode_setattr returned %d\n", - ret); + "%s: orangefs_inode_setattr returned %d\n", + __func__, + ret); if (!ret && (iattr->ia_valid & ATTR_MODE)) /* change mod on a file that has ACLs */ ret = posix_acl_chmod(inode, inode->i_mode); out: - gossip_debug(GOSSIP_INODE_DEBUG, "orangefs_setattr: returning %d\n", ret); + gossip_debug(GOSSIP_INODE_DEBUG, "%s: ret:%d:\n", __func__, ret); return ret; } @@ -262,13 +263,19 @@ int orangefs_getattr(const struct path *path, struct kstat *stat, /* override block size reported to stat */ orangefs_inode = ORANGEFS_I(inode); - stat->blksize = orangefs_inode->blksize; if (request_mask & STATX_SIZE) stat->result_mask = STATX_BASIC_STATS; else stat->result_mask = STATX_BASIC_STATS & ~STATX_SIZE; + + stat->attributes_mask = STATX_ATTR_IMMUTABLE | + STATX_ATTR_APPEND; + if (inode->i_flags & S_IMMUTABLE) + stat->attributes |= STATX_ATTR_IMMUTABLE; + if (inode->i_flags & S_APPEND) + stat->attributes |= STATX_ATTR_APPEND; } return ret; } @@ -306,8 +313,8 @@ int orangefs_update_time(struct inode *inode, struct timespec *time, int flags) return orangefs_inode_setattr(inode, &iattr); } -/* ORANGEDS2 implementation of VFS inode operations for files */ -const struct inode_operations orangefs_file_inode_operations = { +/* ORANGEFS2 implementation of VFS inode operations for files */ +static const struct inode_operations orangefs_file_inode_operations = { .get_acl = orangefs_get_acl, .set_acl = orangefs_set_acl, .setattr = orangefs_setattr, @@ -325,7 +332,6 @@ static int orangefs_init_iops(struct inode *inode) case S_IFREG: inode->i_op = &orangefs_file_inode_operations; inode->i_fop = &orangefs_file_operations; - inode->i_blkbits = PAGE_SHIFT; break; case S_IFLNK: inode->i_op = &orangefs_symlink_inode_operations; @@ -345,8 +351,8 @@ static int orangefs_init_iops(struct inode *inode) } /* - * Given a ORANGEFS object identifier (fsid, handle), convert it into a ino_t type - * that will be used as a hash-index from where the handle will + * Given an ORANGEFS object identifier (fsid, handle), convert it into + * a ino_t type that will be used as a hash-index from where the handle will * be searched for in the VFS hash table of inodes. */ static inline ino_t orangefs_handle_hash(struct orangefs_object_kref *ref) @@ -376,8 +382,10 @@ static int orangefs_test_inode(struct inode *inode, void *data) struct orangefs_inode_s *orangefs_inode = NULL; orangefs_inode = ORANGEFS_I(inode); - return (!ORANGEFS_khandle_cmp(&(orangefs_inode->refn.khandle), &(ref->khandle)) - && orangefs_inode->refn.fs_id == ref->fs_id); + /* test handles and fs_ids... */ + return (!ORANGEFS_khandle_cmp(&(orangefs_inode->refn.khandle), + &(ref->khandle)) && + orangefs_inode->refn.fs_id == ref->fs_id); } /* @@ -385,16 +393,21 @@ static int orangefs_test_inode(struct inode *inode, void *data) * file handle. * * @sb: the file system super block instance. - * @ref: The ORANGEFS object for which we are trying to locate an inode structure. + * @ref: The ORANGEFS object for which we are trying to locate an inode. */ -struct inode *orangefs_iget(struct super_block *sb, struct orangefs_object_kref *ref) +struct inode *orangefs_iget(struct super_block *sb, + struct orangefs_object_kref *ref) { struct inode *inode = NULL; unsigned long hash; int error; hash = orangefs_handle_hash(ref); - inode = iget5_locked(sb, hash, orangefs_test_inode, orangefs_set_inode, ref); + inode = iget5_locked(sb, + hash, + orangefs_test_inode, + orangefs_set_inode, + ref); if (!inode || !(inode->i_state & I_NEW)) return inode; diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index 6e3134e6d98a..625b0580f9be 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c @@ -75,8 +75,7 @@ static int orangefs_create(struct inode *dir, get_khandle_from_ino(inode), dentry); - d_instantiate(dentry, inode); - unlock_new_inode(inode); + d_instantiate_new(dentry, inode); orangefs_set_timeout(dentry); ORANGEFS_I(inode)->getattr_time = jiffies - 1; ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; @@ -111,7 +110,6 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_kernel_op_s *new_op; struct inode *inode; - struct dentry *res; int ret = -EINVAL; /* @@ -159,65 +157,18 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, new_op->downcall.resp.lookup.refn.fs_id, ret); - if (ret < 0) { - if (ret == -ENOENT) { - /* - * if no inode was found, add a negative dentry to - * dcache anyway; if we don't, we don't hold expected - * lookup semantics and we most noticeably break - * during directory renames. - * - * however, if the operation failed or exited, do not - * add the dentry (e.g. in the case that a touch is - * issued on a file that already exists that was - * interrupted during this lookup -- no need to add - * another negative dentry for an existing file) - */ - - gossip_debug(GOSSIP_NAME_DEBUG, - "orangefs_lookup: Adding *negative* dentry " - "%p for %pd\n", - dentry, - dentry); - - d_add(dentry, NULL); - res = NULL; - goto out; - } - + if (ret >= 0) { + orangefs_set_timeout(dentry); + inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); + } else if (ret == -ENOENT) { + inode = NULL; + } else { /* must be a non-recoverable error */ - res = ERR_PTR(ret); - goto out; - } - - orangefs_set_timeout(dentry); - - inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); - if (IS_ERR(inode)) { - gossip_debug(GOSSIP_NAME_DEBUG, - "error %ld from iget\n", PTR_ERR(inode)); - res = ERR_CAST(inode); - goto out; + inode = ERR_PTR(ret); } - gossip_debug(GOSSIP_NAME_DEBUG, - "%s:%s:%d " - "Found good inode [%lu] with count [%d]\n", - __FILE__, - __func__, - __LINE__, - inode->i_ino, - (int)atomic_read(&inode->i_count)); - - /* update dentry/inode pair into dcache */ - res = d_splice_alias(inode, dentry); - - gossip_debug(GOSSIP_NAME_DEBUG, - "Lookup success (inode ct = %d)\n", - (int)atomic_read(&inode->i_count)); -out: op_release(new_op); - return res; + return d_splice_alias(inode, dentry); } /* return 0 on success; non-zero otherwise */ @@ -327,13 +278,19 @@ static int orangefs_symlink(struct inode *dir, ret = PTR_ERR(inode); goto out; } + /* + * This is necessary because orangefs_inode_getattr will not + * re-read symlink size as it is impossible for it to change. + * Invalidating the cache does not help. orangefs_new_inode + * does not set the correct size (it does not know symname). + */ + inode->i_size = strlen(symname); gossip_debug(GOSSIP_NAME_DEBUG, "Assigned symlink inode new number of %pU\n", get_khandle_from_ino(inode)); - d_instantiate(dentry, inode); - unlock_new_inode(inode); + d_instantiate_new(dentry, inode); orangefs_set_timeout(dentry); ORANGEFS_I(inode)->getattr_time = jiffies - 1; ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; @@ -402,8 +359,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode "Assigned dir inode new number of %pU\n", get_khandle_from_ino(inode)); - d_instantiate(dentry, inode); - unlock_new_inode(inode); + d_instantiate_new(dentry, inode); orangefs_set_timeout(dentry); ORANGEFS_I(inode)->getattr_time = jiffies - 1; ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c index 59f444dced9b..c4e98c9c1621 100644 --- a/fs/orangefs/orangefs-bufmap.c +++ b/fs/orangefs/orangefs-bufmap.c @@ -71,9 +71,9 @@ static void put(struct slot_map *m, int slot) spin_lock(&m->q.lock); __clear_bit(slot, m->map); v = ++m->c; - if (unlikely(v == 1)) /* no free slots -> one free slot */ + if (v > 0) wake_up_locked(&m->q); - else if (unlikely(v == -1)) /* finished dying */ + if (unlikely(v == -1)) /* finished dying */ wake_up_all_locked(&m->q); spin_unlock(&m->q.lock); } @@ -138,7 +138,7 @@ static int get(struct slot_map *m) /* used to describe mapped buffers */ struct orangefs_bufmap_desc { - void *uaddr; /* user space address pointer */ + void __user *uaddr; /* user space address pointer */ struct page **page_array; /* array of mapped pages */ int array_count; /* size of above arrays */ struct list_head list_link; @@ -184,7 +184,7 @@ orangefs_bufmap_free(struct orangefs_bufmap *bufmap) } /* - * XXX: Can the size and shift change while the caller gives up the + * XXX: Can the size and shift change while the caller gives up the * XXX: lock between calling this and doing something useful? */ @@ -215,20 +215,6 @@ int orangefs_bufmap_shift_query(void) static DECLARE_WAIT_QUEUE_HEAD(bufmap_waitq); static DECLARE_WAIT_QUEUE_HEAD(readdir_waitq); -/* - * orangefs_get_bufmap_init - * - * If bufmap_init is 1, then the shared memory system, including the - * buffer_index_array, is available. Otherwise, it is not. - * - * returns the value of bufmap_init - */ -int orangefs_get_bufmap_init(void) -{ - return __orangefs_bufmap ? 1 : 0; -} - - static struct orangefs_bufmap * orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc) { @@ -496,7 +482,7 @@ void orangefs_readdir_index_put(int buffer_index) } /* - * we've been handed an iovec, we need to copy it to + * we've been handed an iovec, we need to copy it to * the shared memory descriptor at "buffer_index". */ int orangefs_bufmap_copy_from_iovec(struct iov_iter *iter, diff --git a/fs/orangefs/orangefs-debug.h b/fs/orangefs/orangefs-debug.h index c7db56a31b92..6e079d4230d0 100644 --- a/fs/orangefs/orangefs-debug.h +++ b/fs/orangefs/orangefs-debug.h @@ -43,12 +43,6 @@ #define GOSSIP_MAX_NR 16 #define GOSSIP_MAX_DEBUG (((__u64)1 << GOSSIP_MAX_NR) - 1) -/*function prototypes*/ -__u64 ORANGEFS_kmod_eventlog_to_mask(const char *event_logging); -__u64 ORANGEFS_debug_eventlog_to_mask(const char *event_logging); -char *ORANGEFS_debug_mask_to_eventlog(__u64 mask); -char *ORANGEFS_kmod_mask_to_eventlog(__u64 mask); - /* a private internal type */ struct __keyword_mask_s { const char *keyword; diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c index 6e35f2f3c897..0732cb08173e 100644 --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -114,7 +114,7 @@ static const struct seq_operations help_debug_ops = { .show = help_show, }; -const struct file_operations debug_help_fops = { +static const struct file_operations debug_help_fops = { .owner = THIS_MODULE, .open = orangefs_debug_help_open, .read = seq_read, diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index eebbaece85ef..004511617b6d 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h @@ -65,11 +65,7 @@ #define ORANGEFS_REQDEVICE_NAME "pvfs2-req" #define ORANGEFS_DEVREQ_MAGIC 0x20030529 -#define ORANGEFS_LINK_MAX 0x000000FF #define ORANGEFS_PURGE_RETRY_COUNT 0x00000005 -#define ORANGEFS_MAX_NUM_OPTIONS 0x00000004 -#define ORANGEFS_MAX_MOUNT_OPT_LEN 0x00000080 -#define ORANGEFS_MAX_FSKEY_LEN 64 #define MAX_DEV_REQ_UPSIZE (2 * sizeof(__s32) + \ sizeof(__u64) + sizeof(struct orangefs_upcall_s)) @@ -113,15 +109,6 @@ extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type); extern int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type); /* - * Redefine xtvec structure so that we could move helper functions out of - * the define - */ -struct xtvec { - __kernel_off_t xtv_off; /* must be off_t */ - __kernel_size_t xtv_len; /* must be size_t */ -}; - -/* * orangefs data structures */ struct orangefs_kernel_op_s { @@ -195,7 +182,6 @@ static inline void set_op_state_purged(struct orangefs_kernel_op_s *op) struct orangefs_inode_s { struct orangefs_object_kref refn; char link_target[ORANGEFS_NAME_MAX]; - __s64 blksize; /* * Reading/Writing Extended attributes need to acquire the appropriate * reader/writer semaphore on the orangefs_inode_s structure. @@ -224,39 +210,6 @@ struct orangefs_sb_info_s { struct list_head list; }; -/* - * structure that holds the state of any async I/O operation issued - * through the VFS. Needed especially to handle cancellation requests - * or even completion notification so that the VFS client-side daemon - * can free up its vfs_request slots. - */ -struct orangefs_kiocb_s { - /* the pointer to the task that initiated the AIO */ - struct task_struct *tsk; - - /* pointer to the kiocb that kicked this operation */ - struct kiocb *kiocb; - - /* buffer index that was used for the I/O */ - struct orangefs_bufmap *bufmap; - int buffer_index; - - /* orangefs kernel operation type */ - struct orangefs_kernel_op_s *op; - - /* set to indicate the type of the operation */ - int rw; - - /* file offset */ - loff_t offset; - - /* and the count in bytes */ - size_t bytes_to_be_copied; - - ssize_t bytes_copied; - int needs_cleanup; -}; - struct orangefs_stats { unsigned long cache_hits; unsigned long cache_misses; @@ -305,21 +258,6 @@ static inline struct orangefs_khandle *get_khandle_from_ino(struct inode *inode) return &(ORANGEFS_I(inode)->refn.khandle); } -static inline ino_t get_ino_from_khandle(struct inode *inode) -{ - struct orangefs_khandle *khandle; - ino_t ino; - - khandle = get_khandle_from_ino(inode); - ino = orangefs_khandle_to_ino(khandle); - return ino; -} - -static inline ino_t get_parent_ino_from_dentry(struct dentry *dentry) -{ - return get_ino_from_khandle(dentry->d_parent->d_inode); -} - static inline int is_root_handle(struct inode *inode) { gossip_debug(GOSSIP_DCACHE_DEBUG, @@ -391,7 +329,6 @@ void fsid_key_table_finalize(void); /* * defined in inode.c */ -__u32 convert_to_orangefs_mask(unsigned long lite_mask); struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, int mode, @@ -410,17 +347,6 @@ int orangefs_update_time(struct inode *, struct timespec *, int); /* * defined in xattr.c */ -int orangefs_setxattr(struct dentry *dentry, - const char *name, - const void *value, - size_t size, - int flags); - -ssize_t orangefs_getxattr(struct dentry *dentry, - const char *name, - void *buffer, - size_t size); - ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size); /* @@ -467,8 +393,6 @@ int orangefs_inode_check_changed(struct inode *inode); int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr); -int orangefs_unmount_sb(struct super_block *sb); - bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op); int orangefs_normalize_to_errno(__s32 error_code); @@ -487,16 +411,11 @@ extern struct list_head *orangefs_htable_ops_in_progress; extern spinlock_t orangefs_htable_ops_in_progress_lock; extern int hash_table_size; -extern const struct address_space_operations orangefs_address_operations; -extern const struct inode_operations orangefs_file_inode_operations; extern const struct file_operations orangefs_file_operations; extern const struct inode_operations orangefs_symlink_inode_operations; extern const struct inode_operations orangefs_dir_inode_operations; extern const struct file_operations orangefs_dir_operations; extern const struct dentry_operations orangefs_dentry_operations; -extern const struct file_operations orangefs_devreq_file_operations; - -extern wait_queue_head_t orangefs_bufmap_init_waitq; /* * misc convenience macros diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c index 00fadaf0da8f..804c8a261e4b 100644 --- a/fs/orangefs/orangefs-utils.c +++ b/fs/orangefs/orangefs-utils.c @@ -183,9 +183,9 @@ static inline int copy_attributes_from_inode(struct inode *inode, attrs->mask |= ORANGEFS_ATTR_SYS_CTIME; /* - * ORANGEFS cannot set size with a setattr operation. Probably not likely - * to be requested through the VFS, but just in case, don't worry about - * ATTR_SIZE + * ORANGEFS cannot set size with a setattr operation. Probably not + * likely to be requested through the VFS, but just in case, don't + * worry about ATTR_SIZE */ if (iattr->ia_valid & ATTR_MODE) { @@ -200,14 +200,16 @@ static inline int copy_attributes_from_inode(struct inode *inode, tmp_mode -= S_ISVTX; } else { gossip_debug(GOSSIP_UTILS_DEBUG, - "User attempted to set sticky bit on non-root directory; returning EINVAL.\n"); + "%s: setting sticky bit not supported.\n", + __func__); return -EINVAL; } } if (tmp_mode & (S_ISUID)) { gossip_debug(GOSSIP_UTILS_DEBUG, - "Attempting to set setuid bit (not supported); returning EINVAL.\n"); + "%s: setting setuid bit not supported.\n", + __func__); return -EINVAL; } @@ -275,7 +277,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, { struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_kernel_op_s *new_op; - loff_t inode_size, rounded_up_size; + loff_t inode_size; int ret, type; gossip_debug(GOSSIP_UTILS_DEBUG, "%s: called on inode %pU\n", __func__, @@ -330,22 +332,19 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, if (request_mask & STATX_SIZE || new) { inode_size = (loff_t)new_op-> downcall.resp.getattr.attributes.size; - rounded_up_size = - (inode_size + (4096 - (inode_size % 4096))); inode->i_size = inode_size; - orangefs_inode->blksize = - new_op->downcall.resp.getattr.attributes.blksize; + inode->i_blkbits = ffs(new_op->downcall.resp.getattr. + attributes.blksize); spin_lock(&inode->i_lock); inode->i_bytes = inode_size; inode->i_blocks = - (unsigned long)(rounded_up_size / 512); + (inode_size + 512 - inode_size % 512)/512; spin_unlock(&inode->i_lock); } break; case S_IFDIR: if (request_mask & STATX_SIZE || new) { inode->i_size = PAGE_SIZE; - orangefs_inode->blksize = i_blocksize(inode); spin_lock(&inode->i_lock); inode_set_bytes(inode, inode->i_size); spin_unlock(&inode->i_lock); @@ -356,7 +355,6 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, if (new) { inode->i_size = (loff_t)strlen(new_op-> downcall.resp.getattr.link_target); - orangefs_inode->blksize = i_blocksize(inode); ret = strscpy(orangefs_inode->link_target, new_op->downcall.resp.getattr.link_target, ORANGEFS_NAME_MAX); @@ -525,7 +523,9 @@ int orangefs_normalize_to_errno(__s32 error_code) error_code = -ETIMEDOUT; } else { /* assume a default error code */ - gossip_err("orangefs: warning: got error code without errno equivalent: %d.\n", error_code); + gossip_err("%s: bad error code :%d:.\n", + __func__, + error_code); error_code = -EINVAL; } @@ -542,7 +542,7 @@ int orangefs_normalize_to_errno(__s32 error_code) * there is a bug somewhere. */ } else { - gossip_err("orangefs: orangefs_normalize_to_errno: got error code which is not from ORANGEFS.\n"); + gossip_err("%s: unknown error code.\n", __func__); error_code = -EINVAL; } return error_code; diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index dc6e3e6269c3..d403cf29a99b 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h @@ -5,11 +5,6 @@ #include <linux/slab.h> #include <linux/ioctl.h> -/* pvfs2-config.h ***********************************************************/ -#define ORANGEFS_VERSION_MAJOR 2 -#define ORANGEFS_VERSION_MINOR 9 -#define ORANGEFS_VERSION_SUB 0 - /* khandle stuff ***********************************************************/ /* @@ -70,16 +65,6 @@ static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh, } /* pvfs2-types.h ************************************************************/ -typedef __u32 ORANGEFS_uid; -typedef __u32 ORANGEFS_gid; -typedef __s32 ORANGEFS_fs_id; -typedef __u32 ORANGEFS_permissions; -typedef __u64 ORANGEFS_time; -typedef __s64 ORANGEFS_size; -typedef __u64 ORANGEFS_flags; -typedef __u64 ORANGEFS_ds_position; -typedef __s32 ORANGEFS_error; -typedef __s64 ORANGEFS_offset; #define ORANGEFS_SUPER_MAGIC 0x20030528 @@ -145,7 +130,6 @@ typedef __s64 ORANGEFS_offset; #define ORANGEFS_APPEND_FL FS_APPEND_FL #define ORANGEFS_NOATIME_FL FS_NOATIME_FL #define ORANGEFS_MIRROR_FL 0x01000000ULL -#define ORANGEFS_O_EXECUTE (1 << 0) #define ORANGEFS_FS_ID_NULL ((__s32)0) #define ORANGEFS_ATTR_SYS_UID (1 << 0) #define ORANGEFS_ATTR_SYS_GID (1 << 1) @@ -229,35 +213,6 @@ enum orangefs_ds_type { ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ }; -/* - * ORANGEFS_certificate simply stores a buffer with the buffer size. - * The buffer can be converted to an OpenSSL X509 struct for use. - */ -struct ORANGEFS_certificate { - __u32 buf_size; - unsigned char *buf; -}; - -/* - * A credential identifies a user and is signed by the client/user - * private key. - */ -struct ORANGEFS_credential { - __u32 userid; /* user id */ - __u32 num_groups; /* length of group_array */ - __u32 *group_array; /* groups for which the user is a member */ - char *issuer; /* alias of the issuing server */ - __u64 timeout; /* seconds after epoch to time out */ - __u32 sig_size; /* length of the signature in bytes */ - unsigned char *signature; /* digital signature */ - struct ORANGEFS_certificate certificate; /* user certificate buffer */ -}; -#define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \ - sizeof(__u32) + \ - ORANGEFS_REQ_LIMIT_ISSUER + \ - ORANGEFS_REQ_LIMIT_SIGNATURE + \ - extra_size_ORANGEFS_certificate) - /* This structure is used by the VFS-client interaction alone */ struct ORANGEFS_keyval_pair { char key[ORANGEFS_MAX_XATTR_NAMELEN]; @@ -387,7 +342,7 @@ enum { * that may be 32 bit! */ struct ORANGEFS_dev_map_desc { - void *ptr; + void __user *ptr; __s32 total_size; __s32 size; __s32 count; diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 3ae5fdba0225..dfaee90d30bd 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -156,9 +156,10 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf) sb = dentry->d_sb; gossip_debug(GOSSIP_SUPER_DEBUG, - "orangefs_statfs: called on sb %p (fs_id is %d)\n", - sb, - (int)(ORANGEFS_SB(sb)->fs_id)); + "%s: called on sb %p (fs_id is %d)\n", + __func__, + sb, + (int)(ORANGEFS_SB(sb)->fs_id)); new_op = op_alloc(ORANGEFS_VFS_OP_STATFS); if (!new_op) @@ -198,7 +199,7 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf) out_op_release: op_release(new_op); - gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_statfs: returning %d\n", ret); + gossip_debug(GOSSIP_SUPER_DEBUG, "%s: returning %d\n", __func__, ret); return ret; } @@ -423,8 +424,8 @@ static int orangefs_fill_sb(struct super_block *sb, sb->s_op = &orangefs_s_ops; sb->s_d_op = &orangefs_dentry_operations; - sb->s_blocksize = orangefs_bufmap_size_query(); - sb->s_blocksize_bits = orangefs_bufmap_shift_query(); + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; sb->s_maxbytes = MAX_LFS_FILESIZE; root_object.khandle = ORANGEFS_SB(sb)->root_khandle; @@ -579,6 +580,11 @@ void orangefs_kill_sb(struct super_block *sb) /* provided sb cleanup */ kill_anon_super(sb); + if (!ORANGEFS_SB(sb)) { + mutex_lock(&orangefs_request_mutex); + mutex_unlock(&orangefs_request_mutex); + return; + } /* * issue the unmount to userspace to tell it to remove the * dynamic mount info it has for this superblock diff --git a/fs/orangefs/waitqueue.c b/fs/orangefs/waitqueue.c index 0577d6dba8c8..0729d2645d6a 100644 --- a/fs/orangefs/waitqueue.c +++ b/fs/orangefs/waitqueue.c @@ -17,8 +17,12 @@ #include "orangefs-kernel.h" #include "orangefs-bufmap.h" -static int wait_for_matching_downcall(struct orangefs_kernel_op_s *, long, bool); -static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *); +static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op, + long timeout, + bool interruptible) + __acquires(op->lock); +static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *op) + __releases(op->lock); /* * What we do in this function is to walk the list of operations that are @@ -246,6 +250,7 @@ bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op) */ static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *op) + __releases(op->lock) { /* * handle interrupted cases depending on what state we were in when @@ -313,8 +318,9 @@ static void * Returns with op->lock taken. */ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op, - long timeout, - bool interruptible) + long timeout, + bool interruptible) + __acquires(op->lock) { long n; |