diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-18 03:49:59 (GMT) |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-18 03:49:59 (GMT) |
commit | d65177c1ae7f085723154105c5dc8d9e16ae8265 (patch) | |
tree | 14408129d880d89cc5e937f2810f243ed1e6fcde /fs | |
parent | d41f084a74de860fe879403fbbad13abdf7aea8e (diff) | |
parent | 15578eeb6cd4b74492f26e60624aa1a9a52ddd7b (diff) | |
download | linux-d65177c1ae7f085723154105c5dc8d9e16ae8265.tar.xz |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
58 files changed, 1180 insertions, 662 deletions
diff --git a/fs/9p/conv.c b/fs/9p/conv.c index 55ccfa1..32a9f99 100644 --- a/fs/9p/conv.c +++ b/fs/9p/conv.c @@ -56,7 +56,7 @@ static inline int buf_check_overflow(struct cbuf *buf) return buf->p > buf->ep; } -static inline int buf_check_size(struct cbuf *buf, int len) +static int buf_check_size(struct cbuf *buf, int len) { if (buf->p + len > buf->ep) { if (buf->p < buf->ep) { @@ -72,7 +72,7 @@ static inline int buf_check_size(struct cbuf *buf, int len) return 1; } -static inline void *buf_alloc(struct cbuf *buf, int len) +static void *buf_alloc(struct cbuf *buf, int len) { void *ret = NULL; @@ -84,7 +84,7 @@ static inline void *buf_alloc(struct cbuf *buf, int len) return ret; } -static inline void buf_put_int8(struct cbuf *buf, u8 val) +static void buf_put_int8(struct cbuf *buf, u8 val) { if (buf_check_size(buf, 1)) { buf->p[0] = val; @@ -92,7 +92,7 @@ static inline void buf_put_int8(struct cbuf *buf, u8 val) } } -static inline void buf_put_int16(struct cbuf *buf, u16 val) +static void buf_put_int16(struct cbuf *buf, u16 val) { if (buf_check_size(buf, 2)) { *(__le16 *) buf->p = cpu_to_le16(val); @@ -100,7 +100,7 @@ static inline void buf_put_int16(struct cbuf *buf, u16 val) } } -static inline void buf_put_int32(struct cbuf *buf, u32 val) +static void buf_put_int32(struct cbuf *buf, u32 val) { if (buf_check_size(buf, 4)) { *(__le32 *)buf->p = cpu_to_le32(val); @@ -108,7 +108,7 @@ static inline void buf_put_int32(struct cbuf *buf, u32 val) } } -static inline void buf_put_int64(struct cbuf *buf, u64 val) +static void buf_put_int64(struct cbuf *buf, u64 val) { if (buf_check_size(buf, 8)) { *(__le64 *)buf->p = cpu_to_le64(val); @@ -116,7 +116,7 @@ static inline void buf_put_int64(struct cbuf *buf, u64 val) } } -static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) +static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) { if (buf_check_size(buf, slen + 2)) { buf_put_int16(buf, slen); @@ -130,7 +130,7 @@ static inline void buf_put_string(struct cbuf *buf, const char *s) buf_put_stringn(buf, s, strlen(s)); } -static inline u8 buf_get_int8(struct cbuf *buf) +static u8 buf_get_int8(struct cbuf *buf) { u8 ret = 0; @@ -142,7 +142,7 @@ static inline u8 buf_get_int8(struct cbuf *buf) return ret; } -static inline u16 buf_get_int16(struct cbuf *buf) +static u16 buf_get_int16(struct cbuf *buf) { u16 ret = 0; @@ -154,7 +154,7 @@ static inline u16 buf_get_int16(struct cbuf *buf) return ret; } -static inline u32 buf_get_int32(struct cbuf *buf) +static u32 buf_get_int32(struct cbuf *buf) { u32 ret = 0; @@ -166,7 +166,7 @@ static inline u32 buf_get_int32(struct cbuf *buf) return ret; } -static inline u64 buf_get_int64(struct cbuf *buf) +static u64 buf_get_int64(struct cbuf *buf) { u64 ret = 0; @@ -178,7 +178,7 @@ static inline u64 buf_get_int64(struct cbuf *buf) return ret; } -static inline void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr) +static void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr) { vstr->len = buf_get_int16(buf); if (!buf_check_overflow(buf) && buf_check_size(buf, vstr->len)) { @@ -190,7 +190,7 @@ static inline void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr) } } -static inline void buf_get_qid(struct cbuf *bufp, struct v9fs_qid *qid) +static void buf_get_qid(struct cbuf *bufp, struct v9fs_qid *qid) { qid->type = buf_get_int8(bufp); qid->version = buf_get_int32(bufp); @@ -254,7 +254,7 @@ static int v9fs_size_wstat(struct v9fs_wstat *wstat, int extended) * */ -static inline void +static void buf_get_stat(struct cbuf *bufp, struct v9fs_stat *stat, int extended) { stat->size = buf_get_int16(bufp); @@ -427,7 +427,7 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p) buf_put_int64(bufp, val); } -static inline void +static void v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) { if (data) { @@ -441,7 +441,7 @@ v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) buf_put_stringn(bufp, data, str->len); } -static inline int +static int v9fs_put_user_data(struct cbuf *bufp, const char __user * data, int count, unsigned char **pdata) { diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index e93a7ae..62d8d4a 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c @@ -195,6 +195,8 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) if (!empty) d_invalidate(dentry); + nd.dentry = dentry; + nd.mnt = mnt; nd.flags = LOOKUP_DIRECTORY; status = (dentry->d_op->d_revalidate)(dentry, &nd); diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index f979ebb..1b117a4 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1218,7 +1218,7 @@ static int writenote(struct memelfnote *men, struct file *file) if (!dump_seek(file, (off))) \ goto end_coredump; -static inline void fill_elf_header(struct elfhdr *elf, int segs) +static void fill_elf_header(struct elfhdr *elf, int segs) { memcpy(elf->e_ident, ELFMAG, SELFMAG); elf->e_ident[EI_CLASS] = ELF_CLASS; @@ -1243,7 +1243,7 @@ static inline void fill_elf_header(struct elfhdr *elf, int segs) return; } -static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset) +static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset) { phdr->p_type = PT_NOTE; phdr->p_offset = offset; diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 9ccc7d8..6a7b730 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -264,7 +264,7 @@ static int unquote(char *from) return p - from; } -static inline char * check_special_flags (char * sfs, Node * e) +static char * check_special_flags (char * sfs, Node * e) { char * p = sfs; int cont = 1; @@ -123,7 +123,7 @@ static void bio_fs_destructor(struct bio *bio) bio_free(bio, fs_bio_set); } -inline void bio_init(struct bio *bio) +void bio_init(struct bio *bio) { bio->bi_next = NULL; bio->bi_bdev = NULL; @@ -253,7 +253,7 @@ inline int bio_hw_segments(request_queue_t *q, struct bio *bio) * the actual data it points to. Reference count of returned * bio will be one. */ -inline void __bio_clone(struct bio *bio, struct bio *bio_src) +void __bio_clone(struct bio *bio, struct bio *bio_src) { request_queue_t *q = bdev_get_queue(bio_src->bi_bdev); diff --git a/fs/buffer.c b/fs/buffer.c index b9bb7ad..3dc712f 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1027,7 +1027,7 @@ try_again: /* Link the buffer to its page */ set_bh_page(bh, page, offset); - bh->b_end_io = NULL; + init_buffer(bh, NULL, NULL); } return head; /* @@ -1165,7 +1165,7 @@ failed: * some of those buffers may be aliases of filesystem data. * grow_dev_page() will go BUG() if this happens. */ -static inline int +static int grow_buffers(struct block_device *bdev, sector_t block, int size) { struct page *page; @@ -1391,7 +1391,7 @@ static void bh_lru_install(struct buffer_head *bh) /* * Look up the bh in this cpu's LRU. If it's there, move it to the head. */ -static inline struct buffer_head * +static struct buffer_head * lookup_bh_lru(struct block_device *bdev, sector_t block, int size) { struct buffer_head *ret = NULL; @@ -1541,7 +1541,7 @@ EXPORT_SYMBOL(set_bh_page); /* * Called when truncating a buffer on a page completely. */ -static inline void discard_buffer(struct buffer_head * bh) +static void discard_buffer(struct buffer_head * bh) { lock_buffer(bh); clear_buffer_dirty(bh); diff --git a/fs/char_dev.c b/fs/char_dev.c index 3b1b1ee..21195c4 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -35,7 +35,7 @@ static struct char_device_struct { unsigned int major; unsigned int baseminor; int minorct; - const char *name; + char name[64]; struct file_operations *fops; struct cdev *cdev; /* will die */ } *chrdevs[MAX_PROBE_HASH]; @@ -46,34 +46,84 @@ static inline int major_to_index(int major) return major % MAX_PROBE_HASH; } -/* get char device names in somewhat random order */ -int get_chrdev_list(char *page) -{ +struct chrdev_info { + int index; struct char_device_struct *cd; - int i, len; +}; - len = sprintf(page, "Character devices:\n"); +void *get_next_chrdev(void *dev) +{ + struct chrdev_info *info; + if (dev == NULL) { + info = kmalloc(sizeof(*info), GFP_KERNEL); + if (!info) + goto out; + info->index=0; + info->cd = chrdevs[info->index]; + if (info->cd) + goto out; + } else { + info = dev; + } + + while (info->index < ARRAY_SIZE(chrdevs)) { + if (info->cd) + info->cd = info->cd->next; + if (info->cd) + goto out; + /* + * No devices on this chain, move to the next + */ + info->index++; + info->cd = (info->index < ARRAY_SIZE(chrdevs)) ? + chrdevs[info->index] : NULL; + if (info->cd) + goto out; + } + +out: + return info; +} + +void *acquire_chrdev_list(void) +{ down(&chrdevs_lock); + return get_next_chrdev(NULL); +} + +void release_chrdev_list(void *dev) +{ + up(&chrdevs_lock); + kfree(dev); +} + + +int count_chrdev_list(void) +{ + struct char_device_struct *cd; + int i, count; + + count = 0; + for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) { - for (cd = chrdevs[i]; cd; cd = cd->next) { - /* - * if the current name, plus the 5 extra characters - * in the device line for this entry - * would run us off the page, we're done - */ - if ((len+strlen(cd->name) + 5) >= PAGE_SIZE) - goto page_full; - - - len += sprintf(page+len, "%3d %s\n", - cd->major, cd->name); - } + for (cd = chrdevs[i]; cd; cd = cd->next) + count++; } -page_full: - up(&chrdevs_lock); - return len; + return count; +} + +int get_chrdev_info(void *dev, int *major, char **name) +{ + struct chrdev_info *info = dev; + + if (info->cd == NULL) + return 1; + + *major = info->cd->major; + *name = info->cd->name; + return 0; } /* @@ -121,7 +171,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, cd->major = major; cd->baseminor = baseminor; cd->minorct = minorct; - cd->name = name; + strncpy(cd->name,name, 64); i = major_to_index(major); diff --git a/fs/compat.c b/fs/compat.c index 271b75d..2468ac1 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1537,7 +1537,7 @@ out_ret: * Ooo, nasty. We need here to frob 32-bit unsigned longs to * 64-bit unsigned longs. */ -static inline +static int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, unsigned long *fdset) { @@ -1570,7 +1570,7 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, return 0; } -static inline +static void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, unsigned long *fdset) { diff --git a/fs/dcache.c b/fs/dcache.c index 134d677..86bdb93 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -94,7 +94,7 @@ static void d_free(struct dentry *dentry) * d_iput() operation if defined. * Called with dcache_lock and per dentry lock held, drops both. */ -static inline void dentry_iput(struct dentry * dentry) +static void dentry_iput(struct dentry * dentry) { struct inode *inode = dentry->d_inode; if (inode) { diff --git a/fs/efs/super.c b/fs/efs/super.c index d8d5ea9..afc4891 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c @@ -222,12 +222,13 @@ static efs_block_t efs_validate_vh(struct volume_header *vh) { sblock); #endif } - return(sblock); + return sblock; } static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) { - if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic))) return -1; + if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic))) + return -1; sb->fs_magic = be32_to_cpu(super->fs_magic); sb->total_blocks = be32_to_cpu(super->fs_size); @@ -575,7 +575,7 @@ static int exec_mmap(struct mm_struct *mm) * disturbing other processes. (Other processes might share the signal * table via the CLONE_SIGHAND option to clone().) */ -static inline int de_thread(struct task_struct *tsk) +static int de_thread(struct task_struct *tsk) { struct signal_struct *sig = tsk->signal; struct sighand_struct *newsighand, *oldsighand = tsk->sighand; @@ -780,7 +780,7 @@ no_thread_group: * so that a new one can be started */ -static inline void flush_old_files(struct files_struct * files) +static void flush_old_files(struct files_struct * files) { long j = -1; struct fdtable *fdt; @@ -964,7 +964,7 @@ int prepare_binprm(struct linux_binprm *bprm) EXPORT_SYMBOL(prepare_binprm); -static inline int unsafe_exec(struct task_struct *p) +static int unsafe_exec(struct task_struct *p) { int unsafe = 0; if (p->ptrace & PT_PTRACED) { diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index c551395..ad1432a 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -83,10 +83,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str if (!inode) return ERR_PTR(-EACCES); } - if (inode) - return d_splice_alias(inode, dentry); - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } struct dentry *ext2_get_parent(struct dentry *child) diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index af193a3..8bd8ac0 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1005,10 +1005,7 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str if (!inode) return ERR_PTR(-EACCES); } - if (inode) - return d_splice_alias(inode, dentry); - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } @@ -36,7 +36,7 @@ void fastcall set_close_on_exec(unsigned int fd, int flag) spin_unlock(&files->file_lock); } -static inline int get_close_on_exec(unsigned int fd) +static int get_close_on_exec(unsigned int fd) { struct files_struct *files = current->files; struct fdtable *fdt; diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e08ab47..4526da8 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -21,18 +21,18 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR); static kmem_cache_t *fuse_req_cachep; -static inline struct fuse_conn *fuse_get_conn(struct file *file) +static struct fuse_conn *fuse_get_conn(struct file *file) { struct fuse_conn *fc; spin_lock(&fuse_lock); fc = file->private_data; - if (fc && !fc->mounted) + if (fc && !fc->connected) fc = NULL; spin_unlock(&fuse_lock); return fc; } -static inline void fuse_request_init(struct fuse_req *req) +static void fuse_request_init(struct fuse_req *req) { memset(req, 0, sizeof(*req)); INIT_LIST_HEAD(&req->list); @@ -53,7 +53,7 @@ void fuse_request_free(struct fuse_req *req) kmem_cache_free(fuse_req_cachep, req); } -static inline void block_sigs(sigset_t *oldset) +static void block_sigs(sigset_t *oldset) { sigset_t mask; @@ -61,7 +61,7 @@ static inline void block_sigs(sigset_t *oldset) sigprocmask(SIG_BLOCK, &mask, oldset); } -static inline void restore_sigs(sigset_t *oldset) +static void restore_sigs(sigset_t *oldset) { sigprocmask(SIG_SETMASK, oldset, NULL); } @@ -109,18 +109,24 @@ struct fuse_req *fuse_get_request(struct fuse_conn *fc) int intr; sigset_t oldset; + atomic_inc(&fc->num_waiting); block_sigs(&oldset); intr = down_interruptible(&fc->outstanding_sem); restore_sigs(&oldset); - return intr ? NULL : do_get_request(fc); + if (intr) { + atomic_dec(&fc->num_waiting); + return NULL; + } + return do_get_request(fc); } static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req) { spin_lock(&fuse_lock); - if (req->preallocated) + if (req->preallocated) { + atomic_dec(&fc->num_waiting); list_add(&req->list, &fc->unused_list); - else + } else fuse_request_free(req); /* If we are in debt decrease that first */ @@ -148,42 +154,23 @@ void fuse_release_background(struct fuse_req *req) spin_unlock(&fuse_lock); } -static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) -{ - int i; - struct fuse_init_out *arg = &req->misc.init_out; - - if (arg->major != FUSE_KERNEL_VERSION) - fc->conn_error = 1; - else { - fc->minor = arg->minor; - fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; - } - - /* After INIT reply is received other requests can go - out. So do (FUSE_MAX_OUTSTANDING - 1) number of - up()s on outstanding_sem. The last up() is done in - fuse_putback_request() */ - for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) - up(&fc->outstanding_sem); -} - /* * This function is called when a request is finished. Either a reply * has arrived or it was interrupted (and not yet sent) or some error - * occurred during communication with userspace, or the device file was - * closed. It decreases the reference count for the request. In case - * of a background request the reference to the stored objects are - * released. The requester thread is woken up (if still waiting), and - * finally the request is either freed or put on the unused_list + * occurred during communication with userspace, or the device file + * was closed. In case of a background request the reference to the + * stored objects are released. The requester thread is woken up (if + * still waiting), the 'end' callback is called if given, else the + * reference to the request is released * * Called with fuse_lock, unlocks it */ static void request_end(struct fuse_conn *fc, struct fuse_req *req) { - int putback; - req->finished = 1; - putback = atomic_dec_and_test(&req->count); + void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; + req->end = NULL; + list_del(&req->list); + req->state = FUSE_REQ_FINISHED; spin_unlock(&fuse_lock); if (req->background) { down_read(&fc->sbput_sem); @@ -192,18 +179,10 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) up_read(&fc->sbput_sem); } wake_up(&req->waitq); - if (req->in.h.opcode == FUSE_INIT) - process_init_reply(fc, req); - else if (req->in.h.opcode == FUSE_RELEASE && req->inode == NULL) { - /* Special case for failed iget in CREATE */ - u64 nodeid = req->in.h.nodeid; - __fuse_get_request(req); - fuse_reset_request(req); - fuse_send_forget(fc, req, nodeid, 1); - putback = 0; - } - if (putback) - fuse_putback_request(fc, req); + if (end) + end(fc, req); + else + fuse_put_request(fc, req); } /* @@ -254,14 +233,16 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) spin_unlock(&fuse_lock); block_sigs(&oldset); - wait_event_interruptible(req->waitq, req->finished); + wait_event_interruptible(req->waitq, req->state == FUSE_REQ_FINISHED); restore_sigs(&oldset); spin_lock(&fuse_lock); - if (req->finished) + if (req->state == FUSE_REQ_FINISHED && !req->interrupted) return; - req->out.h.error = -EINTR; - req->interrupted = 1; + if (!req->interrupted) { + req->out.h.error = -EINTR; + req->interrupted = 1; + } if (req->locked) { /* This is uninterruptible sleep, because data is being copied to/from the buffers of req. During @@ -272,10 +253,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) wait_event(req->waitq, !req->locked); spin_lock(&fuse_lock); } - if (!req->sent && !list_empty(&req->list)) { + if (req->state == FUSE_REQ_PENDING) { list_del(&req->list); __fuse_put_request(req); - } else if (!req->finished && req->sent) + } else if (req->state == FUSE_REQ_SENT) background_request(fc, req); } @@ -310,6 +291,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req) fc->outstanding_debt++; } list_add_tail(&req->list, &fc->pending); + req->state = FUSE_REQ_PENDING; wake_up(&fc->waitq); } @@ -362,34 +344,12 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req) request_send_nowait(fc, req); } -void fuse_send_init(struct fuse_conn *fc) -{ - /* This is called from fuse_read_super() so there's guaranteed - to be a request available */ - struct fuse_req *req = do_get_request(fc); - struct fuse_init_in *arg = &req->misc.init_in; - arg->major = FUSE_KERNEL_VERSION; - arg->minor = FUSE_KERNEL_MINOR_VERSION; - req->in.h.opcode = FUSE_INIT; - req->in.numargs = 1; - req->in.args[0].size = sizeof(*arg); - req->in.args[0].value = arg; - req->out.numargs = 1; - /* Variable length arguement used for backward compatibility - with interface version < 7.5. Rest of init_out is zeroed - by do_get_request(), so a short reply is not a problem */ - req->out.argvar = 1; - req->out.args[0].size = sizeof(struct fuse_init_out); - req->out.args[0].value = &req->misc.init_out; - request_send_background(fc, req); -} - /* * Lock the request. Up to the next unlock_request() there mustn't be * anything that could cause a page-fault. If the request was already * interrupted bail out. */ -static inline int lock_request(struct fuse_req *req) +static int lock_request(struct fuse_req *req) { int err = 0; if (req) { @@ -408,7 +368,7 @@ static inline int lock_request(struct fuse_req *req) * requester thread is currently waiting for it to be unlocked, so * wake it up. */ -static inline void unlock_request(struct fuse_req *req) +static void unlock_request(struct fuse_req *req) { if (req) { spin_lock(&fuse_lock); @@ -444,7 +404,7 @@ static void fuse_copy_init(struct fuse_copy_state *cs, int write, } /* Unmap and put previous page of userspace buffer */ -static inline void fuse_copy_finish(struct fuse_copy_state *cs) +static void fuse_copy_finish(struct fuse_copy_state *cs) { if (cs->mapaddr) { kunmap_atomic(cs->mapaddr, KM_USER0); @@ -493,8 +453,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) } /* Do as much copy to/from userspace buffer as we can */ -static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val, - unsigned *size) +static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) { unsigned ncpy = min(*size, cs->len); if (val) { @@ -514,8 +473,8 @@ static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val, * Copy a page in the request to/from the userspace buffer. Must be * done atomically */ -static inline int fuse_copy_page(struct fuse_copy_state *cs, struct page *page, - unsigned offset, unsigned count, int zeroing) +static int fuse_copy_page(struct fuse_copy_state *cs, struct page *page, + unsigned offset, unsigned count, int zeroing) { if (page && zeroing && count < PAGE_SIZE) { void *mapaddr = kmap_atomic(page, KM_USER1); @@ -597,7 +556,7 @@ static void request_wait(struct fuse_conn *fc) DECLARE_WAITQUEUE(wait, current); add_wait_queue_exclusive(&fc->waitq, &wait); - while (fc->mounted && list_empty(&fc->pending)) { + while (fc->connected && list_empty(&fc->pending)) { set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current)) break; @@ -637,14 +596,15 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, goto err_unlock; request_wait(fc); err = -ENODEV; - if (!fc->mounted) + if (!fc->connected) goto err_unlock; err = -ERESTARTSYS; if (list_empty(&fc->pending)) goto err_unlock; req = list_entry(fc->pending.next, struct fuse_req, list); - list_del_init(&req->list); + req->state = FUSE_REQ_READING; + list_move(&req->list, &fc->io); in = &req->in; reqsize = in->h.len; @@ -677,8 +637,8 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, if (!req->isreply) request_end(fc, req); else { - req->sent = 1; - list_add_tail(&req->list, &fc->processing); + req->state = FUSE_REQ_SENT; + list_move_tail(&req->list, &fc->processing); spin_unlock(&fuse_lock); } return reqsize; @@ -766,17 +726,23 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, goto err_finish; spin_lock(&fuse_lock); + err = -ENOENT; + if (!fc->connected) + goto err_unlock; + req = request_find(fc, oh.unique); err = -EINVAL; if (!req) goto err_unlock; - list_del_init(&req->list); if (req->interrupted) { - request_end(fc, req); + spin_unlock(&fuse_lock); fuse_copy_finish(&cs); + spin_lock(&fuse_lock); + request_end(fc, req); return -ENOENT; } + list_move(&req->list, &fc->io); req->out.h = oh; req->locked = 1; cs.req = req; @@ -830,19 +796,90 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait) return mask; } -/* Abort all requests on the given list (pending or processing) */ +/* + * Abort all requests on the given list (pending or processing) + * + * This function releases and reacquires fuse_lock + */ static void end_requests(struct fuse_conn *fc, struct list_head *head) { while (!list_empty(head)) { struct fuse_req *req; req = list_entry(head->next, struct fuse_req, list); - list_del_init(&req->list); req->out.h.error = -ECONNABORTED; request_end(fc, req); spin_lock(&fuse_lock); } } +/* + * Abort requests under I/O + * + * The requests are set to interrupted and finished, and the request + * waiter is woken up. This will make request_wait_answer() wait + * until the request is unlocked and then return. + * + * If the request is asynchronous, then the end function needs to be + * called after waiting for the request to be unlocked (if it was + * locked). + */ +static void end_io_requests(struct fuse_conn *fc) +{ + while (!list_empty(&fc->io)) { + struct fuse_req *req = + list_entry(fc->io.next, struct fuse_req, list); + void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; + + req->interrupted = 1; + req->out.h.error = -ECONNABORTED; + req->state = FUSE_REQ_FINISHED; + list_del_init(&req->list); + wake_up(&req->waitq); + if (end) { + req->end = NULL; + /* The end function will consume this reference */ + __fuse_get_request(req); + spin_unlock(&fuse_lock); + wait_event(req->waitq, !req->locked); + end(fc, req); + spin_lock(&fuse_lock); + } + } +} + +/* + * Abort all requests. + * + * Emergency exit in case of a malicious or accidental deadlock, or + * just a hung filesystem. + * + * The same effect is usually achievable through killing the + * filesystem daemon and all users of the filesystem. The exception + * is the combination of an asynchronous request and the tricky + * deadlock (see Documentation/filesystems/fuse.txt). + * + * During the aborting, progression of requests from the pending and + * processing lists onto the io list, and progression of new requests + * onto the pending list is prevented by req->connected being false. + * + * Progression of requests under I/O to the processing list is + * prevented by the req->interrupted flag being true for these + * requests. For this reason requests on the io list must be aborted + * first. + */ +void fuse_abort_conn(struct fuse_conn *fc) +{ + spin_lock(&fuse_lock); + if (fc->connected) { + fc->connected = 0; + end_io_requests(fc); + end_requests(fc, &fc->pending); + end_requests(fc, &fc->processing); + wake_up_all(&fc->waitq); + } + spin_unlock(&fuse_lock); +} + static int fuse_dev_release(struct inode *inode, struct file *file) { struct fuse_conn *fc; @@ -853,9 +890,11 @@ static int fuse_dev_release(struct inode *inode, struct file *file) fc->connected = 0; end_requests(fc, &fc->pending); end_requests(fc, &fc->processing); - fuse_release_conn(fc); } spin_unlock(&fuse_lock); + if (fc) + kobject_put(&fc->kobj); + return 0; } diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 417bcee..21fd59c 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -23,8 +23,7 @@ /* * Calculate the time in jiffies until a dentry/attributes are valid */ -static inline unsigned long time_to_jiffies(unsigned long sec, - unsigned long nsec) +static unsigned long time_to_jiffies(unsigned long sec, unsigned long nsec) { struct timespec ts = {sec, nsec}; return jiffies + timespec_to_jiffies(&ts); @@ -157,7 +156,7 @@ static int dir_alias(struct inode *inode) return 0; } -static inline int invalid_nodeid(u64 nodeid) +static int invalid_nodeid(u64 nodeid) { return !nodeid || nodeid == FUSE_ROOT_ID; } @@ -166,7 +165,7 @@ static struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, }; -static inline int valid_mode(int m) +static int valid_mode(int m) { return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); @@ -763,13 +762,6 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file, return 0; } -static inline size_t fuse_send_readdir(struct fuse_req *req, struct file *file, - struct inode *inode, loff_t pos, - size_t count) -{ - return fuse_send_read_common(req, file, inode, pos, count, 1); -} - static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) { int err; @@ -793,7 +785,9 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) } req->num_pages = 1; req->pages[0] = page; - nbytes = fuse_send_readdir(req, file, inode, file->f_pos, PAGE_SIZE); + fuse_read_fill(req, file, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR); + request_send(fc, req); + nbytes = req->out.args[0].size; err = req->out.h.error; fuse_put_request(fc, req); if (!err) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 63d2980..a7ef5e7 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -113,6 +113,14 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir) return err; } +/* Special case for failed iget in CREATE */ +static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req) +{ + u64 nodeid = req->in.h.nodeid; + fuse_reset_request(req); + fuse_send_forget(fc, req, nodeid, 1); +} + void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff, u64 nodeid, struct inode *inode, int flags, int isdir) { @@ -128,6 +136,8 @@ void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff, req->in.args[0].size = sizeof(struct fuse_release_in); req->in.args[0].value = inarg; request_send_background(fc, req); + if (!inode) + req->end = fuse_release_end; kfree(ff); } @@ -240,38 +250,35 @@ static int fuse_fsync(struct file *file, struct dentry *de, int datasync) return fuse_fsync_common(file, de, datasync, 0); } -size_t fuse_send_read_common(struct fuse_req *req, struct file *file, - struct inode *inode, loff_t pos, size_t count, - int isdir) +void fuse_read_fill(struct fuse_req *req, struct file *file, + struct inode *inode, loff_t pos, size_t count, int opcode) { - struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_file *ff = file->private_data; - struct fuse_read_in inarg; + struct fuse_read_in *inarg = &req->misc.read_in; - memset(&inarg, 0, sizeof(struct fuse_read_in)); - inarg.fh = ff->fh; - inarg.offset = pos; - inarg.size = count; - req->in.h.opcode = isdir ? FUSE_READDIR : FUSE_READ; + inarg->fh = ff->fh; + inarg->offset = pos; + inarg->size = count; + req->in.h.opcode = opcode; req->in.h.nodeid = get_node_id(inode); req->inode = inode; req->file = file; req->in.numargs = 1; req->in.args[0].size = sizeof(struct fuse_read_in); - req->in.args[0].value = &inarg; + req->in.args[0].value = inarg; req->out.argpages = 1; req->out.argvar = 1; req->out.numargs = 1; req->out.args[0].size = count; - request_send(fc, req); - return req->out.args[0].size; } -static inline size_t fuse_send_read(struct fuse_req *req, struct file *file, - struct inode *inode, loff_t pos, - size_t count) +static size_t fuse_send_read(struct fuse_req *req, struct file *file, + struct inode *inode, loff_t pos, size_t count) { - return fuse_send_read_common(req, file, inode, pos, count, 0); + struct fuse_conn *fc = get_fuse_conn(inode); + fuse_read_fill(req, file, inode, pos, count, FUSE_READ); + request_send(fc, req); + return req->out.args[0].size; } static int fuse_readpage(struct file *file, struct page *page) @@ -304,21 +311,33 @@ static int fuse_readpage(struct file *file, struct page *page) return err; } -static int fuse_send_readpages(struct fuse_req *req, struct file *file, - struct inode *inode) +static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req) { - loff_t pos = page_offset(req->pages[0]); - size_t count = req->num_pages << PAGE_CACHE_SHIFT; - unsigned i; - req->out.page_zeroing = 1; - fuse_send_read(req, file, inode, pos, count); + int i; + + fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */ + for (i = 0; i < req->num_pages; i++) { struct page *page = req->pages[i]; if (!req->out.h.error) SetPageUptodate(page); + else + SetPageError(page); unlock_page(page); } - return req->out.h.error; + fuse_put_request(fc, req); +} + +static void fuse_send_readpages(struct fuse_req *req, struct file *file, + struct inode *inode) +{ + struct fuse_conn *fc = get_fuse_conn(inode); + loff_t pos = page_offset(req->pages[0]); + size_t count = req->num_pages << PAGE_CACHE_SHIFT; + req->out.page_zeroing = 1; + req->end = fuse_readpages_end; + fuse_read_fill(req, file, inode, pos, count, FUSE_READ); + request_send_background(fc, req); } struct fuse_readpages_data { @@ -338,12 +357,12 @@ static int fuse_readpages_fill(void *_data, struct page *page) (req->num_pages == FUSE_MAX_PAGES_PER_REQ || (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || req->pages[req->num_pages - 1]->index + 1 != page->index)) { - int err = fuse_send_readpages(req, data->file, inode); - if (err) { + fuse_send_readpages(req, data->file, inode); + data->req = req = fuse_get_request(fc); + if (!req) { unlock_page(page); - return err; + return -EINTR; } - fuse_reset_request(req); } req->pages[req->num_pages] = page; req->num_pages ++; @@ -368,10 +387,8 @@ static int fuse_readpages(struct file *file, struct address_space *mapping, return -EINTR; err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); - if (!err && data.req->num_pages) - err = fuse_send_readpages(data.req, file, inode); - fuse_put_request(fc, data.req); - fuse_invalidate_attr(inode); /* atime changed */ + if (!err) + fuse_send_readpages(data.req, file, inode); return err; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 74c8d09..46cf933 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -94,6 +94,11 @@ struct fuse_out { /** Header returned from userspace */ struct fuse_out_header h; + /* + * The following bitfields are not changed during the request + * processing + */ + /** Last argument is variable length (can be shorter than arg->size) */ unsigned argvar:1; @@ -111,12 +116,23 @@ struct fuse_out { struct fuse_arg args[3]; }; +/** The request state */ +enum fuse_req_state { + FUSE_REQ_INIT = 0, + FUSE_REQ_PENDING, + FUSE_REQ_READING, + FUSE_REQ_SENT, + FUSE_REQ_FINISHED +}; + +struct fuse_conn; + /** * A request to the client */ struct fuse_req { - /** This can be on either unused_list, pending or processing - lists in fuse_conn */ + /** This can be on either unused_list, pending processing or + io lists in fuse_conn */ struct list_head list; /** Entry on the background list */ @@ -125,6 +141,12 @@ struct fuse_req { /** refcount */ atomic_t count; + /* + * The following bitfields are either set once before the + * request is queued or setting/clearing them is protected by + * fuse_lock + */ + /** True if the request has reply */ unsigned isreply:1; @@ -140,11 +162,8 @@ struct fuse_req { /** Data is being copied to/from the request */ unsigned locked:1; - /** Request has been sent to userspace */ - unsigned sent:1; - - /** The request is finished */ - unsigned finished:1; + /** State of the request */ + enum fuse_req_state state; /** The request input */ struct fuse_in in; @@ -161,6 +180,7 @@ struct fuse_req { struct fuse_release_in release_in; struct fuse_init_in init_in; struct fuse_init_out init_out; + struct fuse_read_in read_in; } misc; /** page vector */ @@ -180,6 +200,9 @@ struct fuse_req { /** File used in the request (or NULL) */ struct file *file; + + /** Request completion callback */ + void (*end)(struct fuse_conn *, struct fuse_req *); }; /** @@ -190,9 +213,6 @@ struct fuse_req { * unmounted. */ struct fuse_conn { - /** Reference count */ - int count; - /** The user id for this mount */ uid_t user_id; @@ -217,6 +237,9 @@ struct fuse_conn { /** The list of requests being processed */ struct list_head processing; + /** The list of requests under I/O */ + struct list_head io; + /** Requests put in the background (RELEASE or any other interrupted request) */ struct list_head background; @@ -238,14 +261,22 @@ struct fuse_conn { u64 reqctr; /** Mount is active */ - unsigned mounted : 1; + unsigned mounted; - /** Connection established */ - unsigned connected : 1; + /** Connection established, cleared on umount, connection + abort and device release */ + unsigned connected; - /** Connection failed (version mismatch) */ + /** Connection failed (version mismatch). Cannot race with + setting other bitfields since it is only set once in INIT + reply, before any other request, and never cleared */ unsigned conn_error : 1; + /* + * The following bitfields are only for optimization purposes + * and hence races in setting them will not cause malfunction + */ + /** Is fsync not implemented by fs? */ unsigned no_fsync : 1; @@ -273,21 +304,22 @@ struct fuse_conn { /** Is create not implemented by fs? */ unsigned no_create : 1; + /** The number of requests waiting for completion */ + atomic_t num_waiting; + /** Negotiated minor version */ unsigned minor; /** Backing dev info */ struct backing_dev_info bdi; -}; -static inline struct fuse_conn **get_fuse_conn_super_p(struct super_block *sb) -{ - return (struct fuse_conn **) &sb->s_fs_info; -} + /** kobject */ + struct kobject kobj; +}; static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) { - return *get_fuse_conn_super_p(sb); + return sb->s_fs_info; } static inline struct fuse_conn *get_fuse_conn(struct inode *inode) @@ -295,6 +327,11 @@ static inline struct fuse_conn *get_fuse_conn(struct inode *inode) return get_fuse_conn_super(inode->i_sb); } +static inline struct fuse_conn *get_fuse_conn_kobj(struct kobject *obj) +{ + return container_of(obj, struct fuse_conn, kobj); +} + static inline struct fuse_inode *get_fuse_inode(struct inode *inode) { return container_of(inode, struct fuse_inode, inode); @@ -336,11 +373,10 @@ void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, unsigned long nodeid, u64 nlookup); /** - * Send READ or READDIR request + * Initialize READ or READDIR request */ -size_t fuse_send_read_common(struct fuse_req *req, struct file *file, - struct inode *inode, loff_t pos, size_t count, - int isdir); +void fuse_read_fill(struct fuse_req *req, struct file *file, + struct inode *inode, loff_t pos, size_t count, int opcode); /** * Send OPEN or OPENDIR request @@ -395,12 +431,6 @@ void fuse_init_symlink(struct inode *inode); void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr); /** - * Check if the connection can be released, and if yes, then free the - * connection structure - */ -void fuse_release_conn(struct fuse_conn *fc); - -/** * Initialize the client device */ int fuse_dev_init(void); @@ -456,6 +486,9 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req); */ void fuse_release_background(struct fuse_req *req); +/* Abort all requests */ +void fuse_abort_conn(struct fuse_conn *fc); + /** * Get the attributes of a file */ @@ -465,8 +498,3 @@ int fuse_do_getattr(struct inode *inode); * Invalidate inode attributes */ void fuse_invalidate_attr(struct inode *inode); - -/** - * Send the INIT message - */ -void fuse_send_init(struct fuse_conn *fc); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 04c80cc..c755a04 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -24,6 +24,13 @@ MODULE_LICENSE("GPL"); spinlock_t fuse_lock; static kmem_cache_t *fuse_inode_cachep; +static struct subsystem connections_subsys; + +struct fuse_conn_attr { + struct attribute attr; + ssize_t (*show)(struct fuse_conn *, char *); + ssize_t (*store)(struct fuse_conn *, const char *, size_t); +}; #define FUSE_SUPER_MAGIC 0x65735546 @@ -189,6 +196,11 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid, return inode; } +static void fuse_umount_begin(struct super_block *sb) +{ + fuse_abort_conn(get_fuse_conn_super(sb)); +} + static void fuse_put_super(struct super_block *sb) { struct fuse_conn *fc = get_fuse_conn_super(sb); @@ -200,14 +212,13 @@ static void fuse_put_super(struct super_block *sb) spin_lock(&fuse_lock); fc->mounted = 0; - fc->user_id = 0; - fc->group_id = 0; - fc->flags = 0; + fc->connected = 0; + spin_unlock(&fuse_lock); + up_write(&fc->sbput_sem); /* Flush all readers on this fs */ wake_up_all(&fc->waitq); - up_write(&fc->sbput_sem); - fuse_release_conn(fc); - spin_unlock(&fuse_lock); + kobject_del(&fc->kobj); + kobject_put(&fc->kobj); } static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) @@ -356,8 +367,10 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) return 0; } -static void free_conn(struct fuse_conn *fc) +static void fuse_conn_release(struct kobject *kobj) { + struct fuse_conn *fc = get_fuse_conn_kobj(kobj); + while (!list_empty(&fc->unused_list)) { struct fuse_req *req; req = list_entry(fc->unused_list.next, struct fuse_req, list); @@ -367,33 +380,28 @@ static void free_conn(struct fuse_conn *fc) kfree(fc); } -/* Must be called with the fuse lock held */ -void fuse_release_conn(struct fuse_conn *fc) -{ - fc->count--; - if (!fc->count) - free_conn(fc); -} - static struct fuse_conn *new_conn(void) { struct fuse_conn *fc; - fc = kmalloc(sizeof(*fc), GFP_KERNEL); - if (fc != NULL) { + fc = kzalloc(sizeof(*fc), GFP_KERNEL); + if (fc) { int i; - memset(fc, 0, sizeof(*fc)); init_waitqueue_head(&fc->waitq); INIT_LIST_HEAD(&fc->pending); INIT_LIST_HEAD(&fc->processing); + INIT_LIST_HEAD(&fc->io); INIT_LIST_HEAD(&fc->unused_list); INIT_LIST_HEAD(&fc->background); - sema_init(&fc->outstanding_sem, 0); + sema_init(&fc->outstanding_sem, 1); /* One for INIT */ init_rwsem(&fc->sbput_sem); + kobj_set_kset_s(fc, connections_subsys); + kobject_init(&fc->kobj); + atomic_set(&fc->num_waiting, 0); for (i = 0; i < FUSE_MAX_OUTSTANDING; i++) { struct fuse_req *req = fuse_request_alloc(); if (!req) { - free_conn(fc); + kobject_put(&fc->kobj); return NULL; } list_add(&req->list, &fc->unused_list); @@ -408,25 +416,32 @@ static struct fuse_conn *new_conn(void) static struct fuse_conn *get_conn(struct file *file, struct super_block *sb) { struct fuse_conn *fc; + int err; + err = -EINVAL; if (file->f_op != &fuse_dev_operations) - return ERR_PTR(-EINVAL); + goto out_err; + + err = -ENOMEM; fc = new_conn(); - if (fc == NULL) - return ERR_PTR(-ENOMEM); + if (!fc) + goto out_err; + spin_lock(&fuse_lock); - if (file->private_data) { - free_conn(fc); - fc = ERR_PTR(-EINVAL); - } else { - file->private_data = fc; - *get_fuse_conn_super_p(sb) = fc; - fc->mounted = 1; - fc->connected = 1; - fc->count = 2; - } + err = -EINVAL; + if (file->private_data) + goto out_unlock; + + kobject_get(&fc->kobj); + file->private_data = fc; spin_unlock(&fuse_lock); return fc; + + out_unlock: + spin_unlock(&fuse_lock); + kobject_put(&fc->kobj); + out_err: + return ERR_PTR(err); } static struct inode *get_root_inode(struct super_block *sb, unsigned mode) @@ -445,16 +460,74 @@ static struct super_operations fuse_super_operations = { .read_inode = fuse_read_inode, .clear_inode = fuse_clear_inode, .put_super = fuse_put_super, + .umount_begin = fuse_umount_begin, .statfs = fuse_statfs, .show_options = fuse_show_options, }; +static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) +{ + int i; + struct fuse_init_out *arg = &req->misc.init_out; + + if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) + fc->conn_error = 1; + else { + fc->minor = arg->minor; + fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; + } + + /* After INIT reply is received other requests can go + out. So do (FUSE_MAX_OUTSTANDING - 1) number of + up()s on outstanding_sem. The last up() is done in + fuse_putback_request() */ + for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) + up(&fc->outstanding_sem); + + fuse_put_request(fc, req); +} + +static void fuse_send_init(struct fuse_conn *fc) +{ + /* This is called from fuse_read_super() so there's guaranteed + to be exactly one request available */ + struct fuse_req *req = fuse_get_request(fc); + struct fuse_init_in *arg = &req->misc.init_in; + + arg->major = FUSE_KERNEL_VERSION; + arg->minor = FUSE_KERNEL_MINOR_VERSION; + req->in.h.opcode = FUSE_INIT; + req->in.numargs = 1; + req->in.args[0].size = sizeof(*arg); + req->in.args[0].value = arg; + req->out.numargs = 1; + /* Variable length arguement used for backward compatibility + with interface version < 7.5. Rest of init_out is zeroed + by do_get_request(), so a short reply is not a problem */ + req->out.argvar = 1; + req->out.args[0].size = sizeof(struct fuse_init_out); + req->out.args[0].value = &req->misc.init_out; + req->end = process_init_reply; + request_send_background(fc, req); +} + +static unsigned long long conn_id(void) +{ + static unsigned long long ctr = 1; + unsigned long long val; + spin_lock(&fuse_lock); + val = ctr++; + spin_unlock(&fuse_lock); + return val; +} + static int fuse_fill_super(struct super_block *sb, void *data, int silent) { struct fuse_conn *fc; struct inode *root; struct fuse_mount_data d; struct file *file; + struct dentry *root_dentry; int err; if (!parse_fuse_opt((char *) data, &d)) @@ -482,23 +555,42 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages) fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE; + /* Used by get_root_inode() */ + sb->s_fs_info = fc; + err = -ENOMEM; root = get_root_inode(sb, d.rootmode); - if (root == NULL) + if (!root) goto err; - sb->s_root = d_alloc_root(root); - if (!sb->s_root) { + root_dentry = d_alloc_root(root); + if (!root_dentry) { iput(root); goto err; } + + err = kobject_set_name(&fc->kobj, "%llu", conn_id()); + if (err) + goto err_put_root; + + err = kobject_add(&fc->kobj); + if (err) + goto err_put_root; + + sb->s_root = root_dentry; + spin_lock(&fuse_lock); + fc->mounted = 1; + fc->connected = 1; + spin_unlock(&fuse_lock); + fuse_send_init(fc); + return 0; + err_put_root: + dput(root_dentry); err: - spin_lock(&fuse_lock); - fuse_release_conn(fc); - spin_unlock(&fuse_lock); + kobject_put(&fc->kobj); return err; } @@ -516,6 +608,69 @@ static struct file_system_type fuse_fs_type = { .kill_sb = kill_anon_super, }; +static ssize_t fuse_conn_waiting_show(struct fuse_conn *fc, char *page) +{ + return sprintf(page, "%i\n", atomic_read(&fc->num_waiting)); +} + +static ssize_t fuse_conn_abort_store(struct fuse_conn *fc, const char *page, + size_t count) +{ + fuse_abort_conn(fc); + return count; +} + +static struct fuse_conn_attr fuse_conn_waiting = + __ATTR(waiting, 0400, fuse_conn_waiting_show, NULL); +static struct fuse_conn_attr fuse_conn_abort = + __ATTR(abort, 0600, NULL, fuse_conn_abort_store); + +static struct attribute *fuse_conn_attrs[] = { + &fuse_conn_waiting.attr, + &fuse_conn_abort.attr, + NULL, +}; + +static ssize_t fuse_conn_attr_show(struct kobject *kobj, + struct attribute *attr, + char *page) +{ + struct fuse_conn_attr *fca = + container_of(attr, struct fuse_conn_attr, attr); + + if (fca->show) + return fca->show(get_fuse_conn_kobj(kobj), page); + else + return -EACCES; +} + +static ssize_t fuse_conn_attr_store(struct kobject *kobj, + struct attribute *attr, + const char *page, size_t count) +{ + struct fuse_conn_attr *fca = + container_of(attr, struct fuse_conn_attr, attr); + + if (fca->store) + return fca->store(get_fuse_conn_kobj(kobj), page, count); + else + return -EACCES; +} + +static struct sysfs_ops fuse_conn_sysfs_ops = { + .show = &fuse_conn_attr_show, + .store = &fuse_conn_attr_store, +}; + +static struct kobj_type ktype_fuse_conn = { + .release = fuse_conn_release, + .sysfs_ops = &fuse_conn_sysfs_ops, + .default_attrs = fuse_conn_attrs, +}; + +static decl_subsys(fuse, NULL, NULL); +static decl_subsys(connections, &ktype_fuse_conn, NULL); + static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) { @@ -553,6 +708,34 @@ static void fuse_fs_cleanup(void) kmem_cache_destroy(fuse_inode_cachep); } +static int fuse_sysfs_init(void) +{ + int err; + + kset_set_kset_s(&fuse_subsys, fs_subsys); + err = subsystem_register(&fuse_subsys); + if (err) + goto out_err; + + kset_set_kset_s(&connections_subsys, fuse_subsys); + err = subsystem_register(&connections_subsys); + if (err) + goto out_fuse_unregister; + + return 0; + + out_fuse_unregister: + subsystem_unregister(&fuse_subsys); + out_err: + return err; +} + +static void fuse_sysfs_cleanup(void) +{ + subsystem_unregister(&connections_subsys); + subsystem_unregister(&fuse_subsys); +} + static int __init fuse_init(void) { int res; @@ -569,8 +752,14 @@ static int __init fuse_init(void) if (res) goto err_fs_cleanup; + res = fuse_sysfs_init(); + if (res) + goto err_dev_cleanup; + return 0; + err_dev_cleanup: + fuse_dev_cleanup(); err_fs_cleanup: fuse_fs_cleanup(); err: @@ -581,6 +770,7 @@ static void __exit fuse_exit(void) { printk(KERN_DEBUG "fuse exit\n"); + fuse_sysfs_cleanup(); fuse_fs_cleanup(); fuse_dev_cleanup(); } diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ab4c3a9..f568102 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -402,7 +402,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; info = HUGETLBFS_I(inode); - mpol_shared_policy_init(&info->policy); + mpol_shared_policy_init(&info->policy, MPOL_DEFAULT, NULL); switch (mode & S_IFMT) { default: init_special_inode(inode, mode, dev); diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index e37e82b..e7ba0c3 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c @@ -185,8 +185,5 @@ struct dentry *isofs_lookup(struct inode * dir, struct dentry * dentry, struct n } } unlock_kernel(); - if (inode) - return d_splice_alias(inode, dentry); - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index fff108b..70f7a89 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c @@ -47,7 +47,7 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c) ic = next_inode(&i, ic, (c))) -static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, +static void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) { struct jffs2_full_dirent *fd; diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index c79eebb..b635e16 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c @@ -134,7 +134,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_ /* * Allocate and initializes a new fragment. */ -static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size) +static struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size) { struct jffs2_node_frag *newfrag; @@ -513,7 +513,7 @@ free_out: * * Checks the node if we are in the checking stage. */ -static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn) +static int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn) { int ret; diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index f01e9c0..200fbda 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -44,7 +44,7 @@ loff_t_to_s32(loff_t offset) /* * XDR functions for basic NLM types */ -static inline u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c) +static u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c) { unsigned int len; @@ -79,7 +79,7 @@ nlm_encode_cookie(u32 *p, struct nlm_cookie *c) return p; } -static inline u32 * +static u32 * nlm_decode_fh(u32 *p, struct nfs_fh *f) { unsigned int len; @@ -119,7 +119,7 @@ nlm_encode_oh(u32 *p, struct xdr_netobj *oh) return xdr_encode_netobj(p, oh); } -static inline u32 * +static u32 * nlm_decode_lock(u32 *p, struct nlm_lock *lock) { struct file_lock *fl = &lock->fl; diff --git a/fs/mbcache.c b/fs/mbcache.c index 0f1e453..f5bbe4c 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c @@ -126,7 +126,7 @@ __mb_cache_entry_is_hashed(struct mb_cache_entry *ce) } -static inline void +static void __mb_cache_entry_unhash(struct mb_cache_entry *ce) { int n; @@ -139,7 +139,7 @@ __mb_cache_entry_unhash(struct mb_cache_entry *ce) } -static inline void +static void __mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask) { struct mb_cache *cache = ce->e_cache; @@ -158,7 +158,7 @@ __mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask) } -static inline void +static void __mb_cache_entry_release_unlock(struct mb_cache_entry *ce) { /* Wake up all processes queuing for this cache entry. */ @@ -113,7 +113,7 @@ * POSIX.1 2.4: an empty pathname is invalid (ENOENT). * PATH_MAX includes the nul terminator --RR. */ -static inline int do_getname(const char __user *filename, char *page) +static int do_getname(const char __user *filename, char *page) { int retval; unsigned long len = PATH_MAX; @@ -396,7 +396,7 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, * short-cut DAC fails, then call permission() to do more * complete permission check. */ -static inline int exec_permission_lite(struct inode *inode, +static int exec_permission_lite(struct inode *inode, struct nameidata *nd) { umode_t mode = inode->i_mode; @@ -486,7 +486,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s static int __emul_lookup_dentry(const char *, struct nameidata *); /* SMP-safe */ -static inline int +static __always_inline int walk_init_root(const char *name, struct nameidata *nd) { read_lock(¤t->fs->lock); @@ -504,7 +504,7 @@ walk_init_root(const char *name, struct nameidata *nd) return 1; } -static inline int __vfs_follow_link(struct nameidata *nd, const char *link) +static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) { int res = 0; char *name; @@ -544,7 +544,7 @@ struct path { struct dentry *dentry; }; -static inline int __do_follow_link(struct path *path, struct nameidata *nd) +static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd) { int error; void *cookie; @@ -690,7 +690,7 @@ int follow_down(struct vfsmount **mnt, struct dentry **dentry) return 0; } -static inline void follow_dotdot(struct nameidata *nd) +static __always_inline void follow_dotdot(struct nameidata *nd) { while(1) { struct vfsmount *parent; @@ -1294,7 +1294,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode) * 10. We don't allow removal of NFS sillyrenamed files; it's handled by * nfs_async_unlink(). */ -static inline int may_delete(struct inode *dir,struct dentry *victim,int isdir) +static int may_delete(struct inode *dir,struct dentry *victim,int isdir) { int error; @@ -2315,7 +2315,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, return error; } -static inline int do_rename(const char * oldname, const char * newname) +static int do_rename(const char * oldname, const char * newname) { int error = 0; struct dentry * old_dir, * new_dir; diff --git a/fs/namespace.c b/fs/namespace.c index 8bc15b3..ce97bec 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -48,6 +48,10 @@ static int hash_mask __read_mostly, hash_bits __read_mostly; static kmem_cache_t *mnt_cache; static struct rw_semaphore namespace_sem; +/* /sys/fs */ +decl_subsys(fs, NULL, NULL); +EXPORT_SYMBOL_GPL(fs_subsys); + static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) { unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES); @@ -1725,6 +1729,7 @@ void __init mnt_init(unsigned long mempages) i--; } while (i); sysfs_init(); + subsystem_register(&fs_subsys); init_rootfs(); init_mount_tree(); } diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 8c88392..d277a58 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -716,10 +716,8 @@ static void ncp_put_super(struct super_block *sb) fput(server->ncp_filp); kill_proc(server->m.wdog_pid, SIGTERM, 1); - if (server->priv.data) - ncp_kfree_s(server->priv.data, server->priv.len); - if (server->auth.object_name) - ncp_kfree_s(server->auth.object_name, server->auth.object_name_len); + kfree(server->priv.data); + kfree(server->auth.object_name); vfree(server->packet); sb->s_fs_info = NULL; kfree(server); @@ -958,11 +956,6 @@ out: return result; } -#ifdef DEBUG_NCP_MALLOC -int ncp_malloced; -int ncp_current_malloced; -#endif - static struct super_block *ncp_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { @@ -981,10 +974,6 @@ static int __init init_ncp_fs(void) int err; DPRINTK("ncpfs: init_module called\n"); -#ifdef DEBUG_NCP_MALLOC - ncp_malloced = 0; - ncp_current_malloced = 0; -#endif err = init_inodecache(); if (err) goto out1; @@ -1003,10 +992,6 @@ static void __exit exit_ncp_fs(void) DPRINTK("ncpfs: cleanup_module called\n"); unregister_filesystem(&ncp_fs_type); destroy_inodecache(); -#ifdef DEBUG_NCP_MALLOC - PRINTK("ncp_malloced: %d\n", ncp_malloced); - PRINTK("ncp_current_malloced: %d\n", ncp_current_malloced); -#endif } module_init(init_ncp_fs) diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index d6e0c08..eb3813a 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c @@ -518,10 +518,11 @@ outrel: if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN) return -ENOMEM; if (user.object_name_len) { - newname = ncp_kmalloc(user.object_name_len, GFP_USER); - if (!newname) return -ENOMEM; + newname = kmalloc(user.object_name_len, GFP_USER); + if (!newname) + return -ENOMEM; if (copy_from_user(newname, user.object_name, user.object_name_len)) { - ncp_kfree_s(newname, user.object_name_len); + kfree(newname); return -EFAULT; } } else { @@ -540,8 +541,8 @@ outrel: server->priv.len = 0; server->priv.data = NULL; /* leave critical section */ - if (oldprivate) ncp_kfree_s(oldprivate, oldprivatelen); - if (oldname) ncp_kfree_s(oldname, oldnamelen); + kfree(oldprivate); + kfree(oldname); return 0; } case NCP_IOC_GETPRIVATEDATA: @@ -581,10 +582,11 @@ outrel: if (user.len > NCP_PRIVATE_DATA_MAX_LEN) return -ENOMEM; if (user.len) { - new = ncp_kmalloc(user.len, GFP_USER); - if (!new) return -ENOMEM; + new = kmalloc(user.len, GFP_USER); + if (!new) + return -ENOMEM; if (copy_from_user(new, user.data, user.len)) { - ncp_kfree_s(new, user.len); + kfree(new); return -EFAULT; } } else { @@ -596,7 +598,7 @@ outrel: server->priv.len = user.len; server->priv.data = new; /* leave critical section */ - if (old) ncp_kfree_s(old, oldlen); + kfree(old); return 0; } diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index aa7bb41..e3a0797 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -37,7 +37,7 @@ static u32 nfs_ftypes[] = { /* * XDR functions for basic NFS types */ -static inline u32 * +static u32 * decode_fh(u32 *p, struct svc_fh *fhp) { fh_init(fhp, NFS_FHSIZE); @@ -151,7 +151,7 @@ decode_sattr(u32 *p, struct iattr *iap) return p; } -static inline u32 * +static u32 * encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, struct kstat *stat) { diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig index 7490cc9..c9a4780 100644 --- a/fs/partitions/Kconfig +++ b/fs/partitions/Kconfig @@ -222,6 +222,13 @@ config SUN_PARTITION given by the tar program ("man tar" or preferably "info tar"). If you don't know what all this is about, say N. +config KARMA_PARTITION + bool "Karma Partition support" + depends on PARTITION_ADVANCED + help + Say Y here if you would like to mount the Rio Karma MP3 player, as it + uses a proprietary partition table. + config EFI_PARTITION bool "EFI GUID Partition support" depends on PARTITION_ADVANCED diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile index 66d5cc2..42c7d38 100644 --- a/fs/partitions/Makefile +++ b/fs/partitions/Makefile @@ -17,3 +17,4 @@ obj-$(CONFIG_SUN_PARTITION) += sun.o obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o obj-$(CONFIG_IBM_PARTITION) += ibm.o obj-$(CONFIG_EFI_PARTITION) += efi.o +obj-$(CONFIG_KARMA_PARTITION) += karma.o diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 7881ce0..f924f45 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -35,6 +35,7 @@ #include "ibm.h" #include "ultrix.h" #include "efi.h" +#include "karma.h" #ifdef CONFIG_BLK_DEV_MD extern void md_autodetect_dev(dev_t dev); @@ -103,6 +104,9 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) = #ifdef CONFIG_IBM_PARTITION ibm_partition, #endif +#ifdef CONFIG_KARMA_PARTITION + karma_partition, +#endif NULL }; diff --git a/fs/partitions/karma.c b/fs/partitions/karma.c new file mode 100644 index 0000000..176d89b --- /dev/null +++ b/fs/partitions/karma.c @@ -0,0 +1,57 @@ +/* + * fs/partitions/karma.c + * Rio Karma partition info. + * + * Copyright (C) 2006 Bob Copeland (me@bobcopeland.com) + * based on osf.c + */ + +#include "check.h" +#include "karma.h" + +int karma_partition(struct parsed_partitions *state, struct block_device *bdev) +{ + int i; + int slot = 1; + Sector sect; + unsigned char *data; + struct disklabel { + u8 d_reserved[270]; + struct d_partition { + __le32 p_res; + u8 p_fstype; + u8 p_res2[3]; + __le32 p_offset; + __le32 p_size; + } d_partitions[2]; + u8 d_blank[208]; + __le16 d_magic; + } __attribute__((packed)) *label; + struct d_partition *p; + + data = read_dev_sector(bdev, 0, §); + if (!data) + return -1; + + label = (struct disklabel *)data; + if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) { + put_dev_sector(sect); + return 0; + } + + p = label->d_partitions; + for (i = 0 ; i < 2; i++, p++) { + if (slot == state->limit) + break; + + if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) { + put_partition(state, slot, le32_to_cpu(p->p_offset), + le32_to_cpu(p->p_size)); + } + slot++; + } + printk("\n"); + put_dev_sector(sect); + return 1; +} + diff --git a/fs/partitions/karma.h b/fs/partitions/karma.h new file mode 100644 index 0000000..ecf7d3f --- /dev/null +++ b/fs/partitions/karma.h @@ -0,0 +1,8 @@ +/* + * fs/partitions/karma.h + */ + +#define KARMA_LABEL_MAGIC 0xAB56 + +int karma_partition(struct parsed_partitions *state, struct block_device *bdev); + @@ -50,7 +50,7 @@ void pipe_wait(struct inode * inode) mutex_lock(PIPE_MUTEX(*inode)); } -static inline int +static int pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len) { unsigned long copy; @@ -70,7 +70,7 @@ pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len) return 0; } -static inline int +static int pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len) { unsigned long copy; diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index fb117b7..9bdd077 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c @@ -81,6 +81,30 @@ void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop __proc_device_tree_add_prop(pde, prop); } +void proc_device_tree_remove_prop(struct proc_dir_entry *pde, + struct property *prop) +{ + remove_proc_entry(prop->name, pde); +} + +void proc_device_tree_update_prop(struct proc_dir_entry *pde, + struct property *newprop, + struct property *oldprop) +{ + struct proc_dir_entry *ent; + + for (ent = pde->subdir; ent != NULL; ent = ent->next) + if (ent->data == oldprop) + break; + if (ent == NULL) { + printk(KERN_WARNING "device-tree: property \"%s\" " + " does not exist\n", oldprop->name); + } else { + ent->data = newprop; + ent->size = newprop->length; + } +} + /* * Process a node, adding entries for its children and its properties. */ diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 63bf6c0..8f80142 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -20,6 +20,7 @@ #include <linux/time.h> #include <linux/kernel.h> #include <linux/kernel_stat.h> +#include <linux/fs.h> #include <linux/tty.h> #include <linux/string.h> #include <linux/mman.h> @@ -62,7 +63,6 @@ */ extern int get_hardware_list(char *); extern int get_stram_list(char *); -extern int get_chrdev_list(char *); extern int get_filesystem_list(char *); extern int get_exec_domain_list(char *); extern int get_dma_list(char *); @@ -248,6 +248,154 @@ static int cpuinfo_open(struct inode *inode, struct file *file) { return seq_open(file, &cpuinfo_op); } + +enum devinfo_states { + CHR_HDR, + CHR_LIST, + BLK_HDR, + BLK_LIST, + DEVINFO_DONE +}; + +struct devinfo_state { + void *chrdev; + void *blkdev; + unsigned int num_records; + unsigned int cur_record; + enum devinfo_states state; +}; + +static void *devinfo_start(struct seq_file *f, loff_t *pos) +{ + struct devinfo_state *info = f->private; + + if (*pos) { + if ((info) && (*pos <= info->num_records)) + return info; + return NULL; + } + info = kmalloc(sizeof(*info), GFP_KERNEL); + f->private = info; + info->chrdev = acquire_chrdev_list(); + info->blkdev = acquire_blkdev_list(); + info->state = CHR_HDR; + info->num_records = count_chrdev_list(); + info->num_records += count_blkdev_list(); + info->num_records += 2; /* Character and Block headers */ + *pos = 1; + info->cur_record = *pos; + return info; +} + +static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos) +{ + int idummy; + char *ndummy; + struct devinfo_state *info = f->private; + + switch (info->state) { + case CHR_HDR: + info->state = CHR_LIST; + (*pos)++; + /*fallthrough*/ + case CHR_LIST: + if (get_chrdev_info(info->chrdev,&idummy,&ndummy)) { + /* + * The character dev list is complete + */ + info->state = BLK_HDR; + } else { + info->chrdev = get_next_chrdev(info->chrdev); + } + (*pos)++; + break; + case BLK_HDR: + info->state = BLK_LIST; + (*pos)++; + break; + case BLK_LIST: + if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) { + /* + * The block dev list is complete + */ + info->state = DEVINFO_DONE; + } else { + info->blkdev = get_next_blkdev(info->blkdev); + } + (*pos)++; + break; + case DEVINFO_DONE: + (*pos)++; + info->cur_record = *pos; + info = NULL; + break; + default: + break; + } + if (info) + info->cur_record = *pos; + return info; +} + +static void devinfo_stop(struct seq_file *f, void *v) +{ + struct devinfo_state *info = f->private; + + if (info) { + release_chrdev_list(info->chrdev); + release_blkdev_list(info->blkdev); + f->private = NULL; + kfree(info); + } +} + +static int devinfo_show(struct seq_file *f, void *arg) +{ + int major; + char *name; + struct devinfo_state *info = f->private; + + switch(info->state) { + case CHR_HDR: + seq_printf(f,"Character devices:\n"); + /* fallthrough */ + case CHR_LIST: + if (!get_chrdev_info(info->chrdev,&major,&name)) + seq_printf(f,"%3d %s\n",major,name); + break; + case BLK_HDR: + seq_printf(f,"\nBlock devices:\n"); + /* fallthrough */ + case BLK_LIST: + if (!get_blkdev_info(info->blkdev,&major,&name)) + seq_printf(f,"%3d %s\n",major,name); + break; + default: + break; + } + + return 0; +} + +static struct seq_operations devinfo_op = { + .start = devinfo_start, + .next = devinfo_next, + .stop = devinfo_stop, + .show = devinfo_show, +}; + +static int devinfo_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &devinfo_op); +} + +static struct file_operations proc_devinfo_operations = { + .open = devinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static struct file_operations proc_cpuinfo_operations = { .open = cpuinfo_open, .read = seq_read, @@ -450,14 +598,6 @@ static struct file_operations proc_stat_operations = { .release = single_release, }; -static int devices_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - int len = get_chrdev_list(page); - len += get_blkdev_list(page+len, len); - return proc_calc_metrics(page, start, off, count, eof, len); -} - /* * /proc/interrupts */ @@ -582,7 +722,6 @@ void __init proc_misc_init(void) #ifdef CONFIG_STRAM_PROC {"stram", stram_read_proc}, #endif - {"devices", devices_read_proc}, {"filesystems", filesystems_read_proc}, {"cmdline", cmdline_read_proc}, {"locks", locks_read_proc}, @@ -598,6 +737,7 @@ void __init proc_misc_init(void) entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); if (entry) entry->proc_fops = &proc_kmsg_operations; + create_seq_entry("devices", 0, &proc_devinfo_operations); create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); create_seq_entry("partitions", 0, &proc_partitions_operations); create_seq_entry("stat", 0, &proc_stat_operations); diff --git a/fs/quota_v2.c b/fs/quota_v2.c index 7afcbb1..a4ef91b 100644 --- a/fs/quota_v2.c +++ b/fs/quota_v2.c @@ -35,7 +35,8 @@ static int v2_check_quota_file(struct super_block *sb, int type) size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0); if (size != sizeof(struct v2_disk_dqheader)) { - printk("failed read\n"); + printk("quota_v2: failed read expected=%d got=%d\n", + sizeof(struct v2_disk_dqheader), size); return 0; } if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] || diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 3549067..8f8d8d0 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -375,11 +375,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry, return ERR_PTR(-EIO); } - if (inode) - return d_splice_alias(inode, dentry); - - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } /* diff --git a/fs/smbfs/Makefile b/fs/smbfs/Makefile index 93246b7..6673ee8 100644 --- a/fs/smbfs/Makefile +++ b/fs/smbfs/Makefile @@ -13,7 +13,6 @@ smbfs-objs := proc.o dir.o cache.o sock.o inode.o file.o ioctl.o getopt.o \ EXTRA_CFLAGS += -DSMBFS_PARANOIA #EXTRA_CFLAGS += -DSMBFS_DEBUG #EXTRA_CFLAGS += -DSMBFS_DEBUG_VERBOSE -#EXTRA_CFLAGS += -DDEBUG_SMB_MALLOC #EXTRA_CFLAGS += -DDEBUG_SMB_TIMESTAMP #EXTRA_CFLAGS += -Werror diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c index 6ec88bf..02e3e82 100644 --- a/fs/smbfs/inode.c +++ b/fs/smbfs/inode.c @@ -487,11 +487,11 @@ smb_put_super(struct super_block *sb) if (server->conn_pid) kill_proc(server->conn_pid, SIGTERM, 1); - smb_kfree(server->ops); + kfree(server->ops); smb_unload_nls(server); sb->s_fs_info = NULL; smb_unlock_server(server); - smb_kfree(server); + kfree(server); } static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) @@ -519,11 +519,10 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) sb->s_op = &smb_sops; sb->s_time_gran = 100; - server = smb_kmalloc(sizeof(struct smb_sb_info), GFP_KERNEL); + server = kzalloc(sizeof(struct smb_sb_info), GFP_KERNEL); if (!server) goto out_no_server; sb->s_fs_info = server; - memset(server, 0, sizeof(struct smb_sb_info)); server->super_block = sb; server->mnt = NULL; @@ -542,8 +541,8 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) /* FIXME: move these to the smb_sb_info struct */ VERBOSE("alloc chunk = %d\n", sizeof(struct smb_ops) + sizeof(struct smb_mount_data_kernel)); - mem = smb_kmalloc(sizeof(struct smb_ops) + - sizeof(struct smb_mount_data_kernel), GFP_KERNEL); + mem = kmalloc(sizeof(struct smb_ops) + + sizeof(struct smb_mount_data_kernel), GFP_KERNEL); if (!mem) goto out_no_mem; @@ -621,12 +620,12 @@ out_no_root: out_no_smbiod: smb_unload_nls(server); out_bad_option: - smb_kfree(mem); + kfree(mem); out_no_mem: if (!server->mnt) printk(KERN_ERR "smb_fill_super: allocation failure\n"); sb->s_fs_info = NULL; - smb_kfree(server); + kfree(server); goto out_fail; out_wrong_data: printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver); @@ -782,12 +781,6 @@ out: return error; } -#ifdef DEBUG_SMB_MALLOC -int smb_malloced; -int smb_current_kmalloced; -int smb_current_vmalloced; -#endif - static struct super_block *smb_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { @@ -807,12 +800,6 @@ static int __init init_smb_fs(void) int err; DEBUG1("registering ...\n"); -#ifdef DEBUG_SMB_MALLOC - smb_malloced = 0; - smb_current_kmalloced = 0; - smb_current_vmalloced = 0; -#endif - err = init_inodecache(); if (err) goto out_inode; @@ -837,11 +824,6 @@ static void __exit exit_smb_fs(void) unregister_filesystem(&smb_fs_type); smb_destroy_request_cache(); destroy_inodecache(); -#ifdef DEBUG_SMB_MALLOC - printk(KERN_DEBUG "smb_malloced: %d\n", smb_malloced); - printk(KERN_DEBUG "smb_current_kmalloced: %d\n",smb_current_kmalloced); - printk(KERN_DEBUG "smb_current_vmalloced: %d\n",smb_current_vmalloced); -#endif } module_init(init_smb_fs) diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c index a0f296d..c71c375 100644 --- a/fs/smbfs/request.c +++ b/fs/smbfs/request.c @@ -68,7 +68,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server, goto out; if (bufsize > 0) { - buf = smb_kmalloc(bufsize, GFP_NOFS); + buf = kmalloc(bufsize, GFP_NOFS); if (!buf) { kmem_cache_free(req_cachep, req); return NULL; @@ -124,9 +124,8 @@ static void smb_free_request(struct smb_request *req) { atomic_dec(&req->rq_server->nr_requests); if (req->rq_buffer && !(req->rq_flags & SMB_REQ_STATIC)) - smb_kfree(req->rq_buffer); - if (req->rq_trans2buffer) - smb_kfree(req->rq_trans2buffer); + kfree(req->rq_buffer); + kfree(req->rq_trans2buffer); kmem_cache_free(req_cachep, req); } @@ -183,8 +182,7 @@ static int smb_setup_request(struct smb_request *req) req->rq_err = 0; req->rq_errno = 0; req->rq_fragment = 0; - if (req->rq_trans2buffer) - smb_kfree(req->rq_trans2buffer); + kfree(req->rq_trans2buffer); return 0; } @@ -647,10 +645,9 @@ static int smb_recv_trans2(struct smb_sb_info *server, struct smb_request *req) goto out_too_long; req->rq_trans2bufsize = buf_len; - req->rq_trans2buffer = smb_kmalloc(buf_len, GFP_NOFS); + req->rq_trans2buffer = kzalloc(buf_len, GFP_NOFS); if (!req->rq_trans2buffer) goto out_no_mem; - memset(req->rq_trans2buffer, 0, buf_len); req->rq_parm = req->rq_trans2buffer; req->rq_data = req->rq_trans2buffer + parm_tot; diff --git a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog index 18e3487..f403f8b 100644 --- a/fs/sysv/ChangeLog +++ b/fs/sysv/ChangeLog @@ -54,7 +54,7 @@ Fri Jan 4 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> (sysv_read_super): Likewise. (v7_read_super): Likewise. -Sun Dec 30 2001 Manfred Spraul <manfreds@colorfullife.com> +Sun Dec 30 2001 Manfred Spraul <manfred@colorfullife.com> * dir.c (dir_commit_chunk): Do not set dir->i_version. (sysv_readdir): Likewise. diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index a9f4421..3ada9dc 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -49,7 +49,7 @@ void ufs_free_fragments (struct inode * inode, unsigned fragment, unsigned count sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) @@ -81,8 +81,9 @@ void ufs_free_fragments (struct inode * inode, unsigned fragment, unsigned count for (i = bit; i < end_bit; i++) { if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i)) ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i); - else ufs_error (sb, "ufs_free_fragments", - "bit already cleared for fragment %u", i); + else + ufs_error (sb, "ufs_free_fragments", + "bit already cleared for fragment %u", i); } DQUOT_FREE_BLOCK (inode, count); @@ -143,7 +144,7 @@ void ufs_free_blocks (struct inode * inode, unsigned fragment, unsigned count) { sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) @@ -247,7 +248,7 @@ unsigned ufs_new_fragments (struct inode * inode, __fs32 * p, unsigned fragment, sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); *err = -ENOSPC; lock_super (sb); @@ -407,7 +408,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first (USPI_UBH); + usb1 = ubh_get_usb_first (uspi); count = newcount - oldcount; cgno = ufs_dtog(fragment); @@ -490,7 +491,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); oldcg = cgno; /* @@ -606,7 +607,7 @@ static unsigned ufs_alloccg_block (struct inode * inode, sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); ucg = ubh_get_ucg(UCPI_UBH); if (goal == 0) { @@ -663,7 +664,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb, UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count)) uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first (USPI_UBH); + usb1 = ubh_get_usb_first (uspi); ucg = ubh_get_ucg(UCPI_UBH); if (goal) diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index 0938945..c7a47ed 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c @@ -72,7 +72,7 @@ void ufs_free_inode (struct inode * inode) sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); ino = inode->i_ino; @@ -167,7 +167,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode) ufsi = UFS_I(inode); sbi = UFS_SB(sb); uspi = sbi->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); lock_super (sb); diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 55f4aa1..e0c04e3 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -61,7 +61,7 @@ static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t off int n = 0; - UFSD(("ptrs=uspi->s_apb = %d,double_blocks=%d \n",ptrs,double_blocks)); + UFSD(("ptrs=uspi->s_apb = %d,double_blocks=%ld \n",ptrs,double_blocks)); if (i_block < 0) { ufs_warning(inode->i_sb, "ufs_block_to_path", "block < 0"); } else if (i_block < direct_blocks) { @@ -104,7 +104,7 @@ u64 ufs_frag_map(struct inode *inode, sector_t frag) unsigned flags = UFS_SB(sb)->s_flags; u64 temp = 0L; - UFSD((": frag = %lu depth = %d\n",frag,depth)); + UFSD((": frag = %llu depth = %d\n", (unsigned long long)frag, depth)); UFSD((": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",uspi->s_fpbshift,uspi->s_apbmask,mask)); if (depth == 0) @@ -365,9 +365,10 @@ repeat: sync_dirty_buffer(bh); inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); + UFSD(("result %u\n", tmp + blockoff)); out: brelse (bh); - UFSD(("EXIT, result %u\n", tmp + blockoff)) + UFSD(("EXIT\n")); return result; } @@ -386,7 +387,7 @@ static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf if (!create) { phys64 = ufs_frag_map(inode, fragment); - UFSD(("phys64 = %lu \n",phys64)); + UFSD(("phys64 = %llu \n",phys64)); if (phys64) map_bh(bh_result, sb, phys64); return 0; @@ -401,7 +402,7 @@ static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf lock_kernel(); - UFSD(("ENTER, ino %lu, fragment %u\n", inode->i_ino, fragment)) + UFSD(("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment)) if (fragment < 0) goto abort_negative; if (fragment > diff --git a/fs/ufs/super.c b/fs/ufs/super.c index e9a42c7..d4aacee 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -221,7 +221,7 @@ void ufs_error (struct super_block * sb, const char * function, va_list args; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); if (!(sb->s_flags & MS_RDONLY)) { usb1->fs_clean = UFS_FSBAD; @@ -253,7 +253,7 @@ void ufs_panic (struct super_block * sb, const char * function, va_list args; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); if (!(sb->s_flags & MS_RDONLY)) { usb1->fs_clean = UFS_FSBAD; @@ -420,21 +420,18 @@ static int ufs_read_cylinder_structures (struct super_block *sb) { if (i + uspi->s_fpb > blks) size = (blks - i) * uspi->s_fsize; - if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { + if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) ubh = ubh_bread(sb, fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); - if (!ubh) - goto failed; - ubh_ubhcpymem (space, ubh, size); - sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space; - } - else { + else ubh = ubh_bread(sb, uspi->s_csaddr + i, size); - if (!ubh) - goto failed; - ubh_ubhcpymem(space, ubh, size); - sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space; - } + + if (!ubh) + goto failed; + + ubh_ubhcpymem (space, ubh, size); + sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space; + space += size; ubh_brelse (ubh); ubh = NULL; @@ -539,6 +536,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) struct inode *inode; unsigned block_size, super_block_size; unsigned flags; + unsigned super_block_offset; uspi = NULL; ubh = NULL; @@ -586,10 +584,11 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) if (!uspi) goto failed; + super_block_offset=UFS_SBLOCK; + /* Keep 2Gig file limit. Some UFS variants need to override this but as I don't know which I'll let those in the know loosen the rules */ - switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { case UFS_MOUNT_UFSTYPE_44BSD: UFSD(("ufstype=44bsd\n")) @@ -601,7 +600,8 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; break; case UFS_MOUNT_UFSTYPE_UFS2: - UFSD(("ufstype=ufs2\n")) + UFSD(("ufstype=ufs2\n")); + super_block_offset=SBLOCK_UFS2; uspi->s_fsize = block_size = 512; uspi->s_fmask = ~(512 - 1); uspi->s_fshift = 9; @@ -725,19 +725,16 @@ again: /* * read ufs super block from device */ - if ( (flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { - ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + SBLOCK_UFS2/block_size, super_block_size); - } - else { - ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + UFS_SBLOCK/block_size, super_block_size); - } + + ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + super_block_offset/block_size, super_block_size); + if (!ubh) goto failed; - usb1 = ubh_get_usb_first(USPI_UBH); - usb2 = ubh_get_usb_second(USPI_UBH); - usb3 = ubh_get_usb_third(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); + usb2 = ubh_get_usb_second(uspi); + usb3 = ubh_get_usb_third(uspi); usb = (struct ufs_super_block *) ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; @@ -1006,8 +1003,8 @@ static void ufs_write_super (struct super_block *sb) { UFSD(("ENTER\n")) flags = UFS_SB(sb)->s_flags; uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first(USPI_UBH); - usb3 = ubh_get_usb_third(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); + usb3 = ubh_get_usb_third(uspi); if (!(sb->s_flags & MS_RDONLY)) { usb1->fs_time = cpu_to_fs32(sb, get_seconds()); @@ -1049,8 +1046,8 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) uspi = UFS_SB(sb)->s_uspi; flags = UFS_SB(sb)->s_flags; - usb1 = ubh_get_usb_first(USPI_UBH); - usb3 = ubh_get_usb_third(USPI_UBH); + usb1 = ubh_get_usb_first(uspi); + usb3 = ubh_get_usb_third(uspi); /* * Allow the "check" option to be passed as a remount option. @@ -1124,7 +1121,7 @@ static int ufs_statfs (struct super_block *sb, struct kstatfs *buf) lock_kernel(); uspi = UFS_SB(sb)->s_uspi; - usb1 = ubh_get_usb_first (USPI_UBH); + usb1 = ubh_get_usb_first (uspi); usb = (struct ufs_super_block *) ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; diff --git a/fs/ufs/util.h b/fs/ufs/util.h index b264007..48d6d9b 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -249,18 +249,28 @@ extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head /* - * macros to get important structures from ufs_buffer_head + * macros and inline function to get important structures from ufs_sb_private_info */ -#define ubh_get_usb_first(ubh) \ - ((struct ufs_super_block_first *)((ubh)->bh[0]->b_data)) -#define ubh_get_usb_second(ubh) \ - ((struct ufs_super_block_second *)(ubh)-> \ - bh[UFS_SECTOR_SIZE >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE & ~uspi->s_fmask)) +static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, + unsigned int offset) +{ + unsigned int index; + + index = offset >> uspi->s_fshift; + offset &= ~uspi->s_fmask; + return uspi->s_ubh.bh[index]->b_data + offset; +} + +#define ubh_get_usb_first(uspi) \ + ((struct ufs_super_block_first *)get_usb_offset((uspi), 0)) + +#define ubh_get_usb_second(uspi) \ + ((struct ufs_super_block_second *)get_usb_offset((uspi), UFS_SECTOR_SIZE)) + +#define ubh_get_usb_third(uspi) \ + ((struct ufs_super_block_third *)get_usb_offset((uspi), 2*UFS_SECTOR_SIZE)) -#define ubh_get_usb_third(ubh) \ - ((struct ufs_super_block_third *)((ubh)-> \ - bh[UFS_SECTOR_SIZE*2 >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE*2 & ~uspi->s_fmask))) #define ubh_get_ucg(ubh) \ ((struct ufs_cylinder_group *)((ubh)->bh[0]->b_data)) diff --git a/fs/xfs/linux-2.6/mutex.h b/fs/xfs/linux-2.6/mutex.h index d3369b6..2a88d56 100644 --- a/fs/xfs/linux-2.6/mutex.h +++ b/fs/xfs/linux-2.6/mutex.h @@ -18,18 +18,8 @@ #ifndef __XFS_SUPPORT_MUTEX_H__ #define __XFS_SUPPORT_MUTEX_H__ -#include <linux/spinlock.h> #include <linux/mutex.h> -/* - * Map the mutex'es from IRIX to Linux semaphores. - * - * Destroy just simply initializes to -99 which should block all other - * callers. - */ -#define MUTEX_DEFAULT 0x0 - -typedef struct mutex mutex_t; -//#define mutex_destroy(lock) do{}while(0) +typedef struct mutex mutex_t; #endif /* __XFS_SUPPORT_MUTEX_H__ */ diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 4bd3d03..76c6df3 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c @@ -56,9 +56,6 @@ #include <linux/namei.h> #include <linux/security.h> -#define IS_NOATIME(inode) ((inode->i_sb->s_flags & MS_NOATIME) || \ - (S_ISDIR(inode->i_mode) && inode->i_sb->s_flags & MS_NODIRATIME)) - /* * Get a XFS inode from a given vnode. */ @@ -474,11 +471,14 @@ linvfs_symlink( error = 0; VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); - if (!error && cvp) { - ip = LINVFS_GET_IP(cvp); - d_instantiate(dentry, ip); - validate_fields(dir); - validate_fields(ip); /* size needs update */ + if (likely(!error && cvp)) { + error = linvfs_init_security(cvp, dir); + if (likely(!error)) { + ip = LINVFS_GET_IP(cvp); + d_instantiate(dentry, ip); + validate_fields(dir); + validate_fields(ip); + } } return -error; } diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 7dcdd06..53a00fb2 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c @@ -167,7 +167,7 @@ xfs_Gqm_init(void) xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO; xqm->qm_nrefs = 0; #ifdef DEBUG - xfs_mutex_init(&qcheck_lock, MUTEX_DEFAULT, "qchk"); + mutex_init(&qcheck_lock); #endif return xqm; } @@ -497,7 +497,7 @@ xfs_qm_dqflush_all( int error; if (mp->m_quotainfo == NULL) - return (0); + return 0; niters = 0; again: xfs_qm_mplist_lock(mp); @@ -528,7 +528,7 @@ again: error = xfs_qm_dqflush(dqp, flags); xfs_dqunlock(dqp); if (error) - return (error); + return error; xfs_qm_mplist_lock(mp); if (recl != XFS_QI_MPLRECLAIMS(mp)) { @@ -540,7 +540,7 @@ again: xfs_qm_mplist_unlock(mp); /* return ! busy */ - return (0); + return 0; } /* * Release the group dquot pointers the user dquots may be @@ -599,7 +599,7 @@ xfs_qm_dqpurge_int( int nmisses; if (mp->m_quotainfo == NULL) - return (0); + return 0; dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0; dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0; @@ -796,7 +796,7 @@ xfs_qm_dqattach_one( ASSERT(XFS_DQ_IS_LOCKED(dqp)); } #endif - return (error); + return error; } @@ -897,7 +897,7 @@ xfs_qm_dqattach( (! XFS_NOT_DQATTACHED(mp, ip)) || (ip->i_ino == mp->m_sb.sb_uquotino) || (ip->i_ino == mp->m_sb.sb_gquotino)) - return (0); + return 0; ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || XFS_ISLOCKED_INODE_EXCL(ip)); @@ -984,7 +984,7 @@ xfs_qm_dqattach( else ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); #endif - return (error); + return error; } /* @@ -1049,7 +1049,7 @@ xfs_qm_sync( */ if (! XFS_IS_QUOTA_ON(mp)) { xfs_qm_mplist_unlock(mp); - return (0); + return 0; } FOREACH_DQUOT_IN_MP(dqp, mp) { /* @@ -1109,9 +1109,9 @@ xfs_qm_sync( error = xfs_qm_dqflush(dqp, flush_flags); xfs_dqunlock(dqp); if (error && XFS_FORCED_SHUTDOWN(mp)) - return(0); /* Need to prevent umount failure */ + return 0; /* Need to prevent umount failure */ else if (error) - return (error); + return error; xfs_qm_mplist_lock(mp); if (recl != XFS_QI_MPLRECLAIMS(mp)) { @@ -1124,7 +1124,7 @@ xfs_qm_sync( } xfs_qm_mplist_unlock(mp); - return (0); + return 0; } @@ -1146,7 +1146,7 @@ xfs_qm_init_quotainfo( * Tell XQM that we exist as soon as possible. */ if ((error = xfs_qm_hold_quotafs_ref(mp))) { - return (error); + return error; } qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); @@ -1158,7 +1158,7 @@ xfs_qm_init_quotainfo( if ((error = xfs_qm_init_quotainos(mp))) { kmem_free(qinf, sizeof(xfs_quotainfo_t)); mp->m_quotainfo = NULL; - return (error); + return error; } spinlock_init(&qinf->qi_pinlock, "xfs_qinf_pin"); @@ -1232,7 +1232,7 @@ xfs_qm_init_quotainfo( qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT; } - return (0); + return 0; } @@ -1332,7 +1332,7 @@ xfs_qm_dqget_noattach( */ ASSERT(error != ESRCH); ASSERT(error != ENOENT); - return (error); + return error; } ASSERT(udqp); } @@ -1355,7 +1355,7 @@ xfs_qm_dqget_noattach( xfs_qm_dqrele(udqp); ASSERT(error != ESRCH); ASSERT(error != ENOENT); - return (error); + return error; } ASSERT(gdqp); @@ -1376,7 +1376,7 @@ xfs_qm_dqget_noattach( if (udqp) ASSERT(XFS_DQ_IS_LOCKED(udqp)); if (gdqp) ASSERT(XFS_DQ_IS_LOCKED(gdqp)); #endif - return (0); + return 0; } /* @@ -1404,7 +1404,7 @@ xfs_qm_qino_alloc( XFS_TRANS_PERM_LOG_RES, XFS_CREATE_LOG_COUNT))) { xfs_trans_cancel(tp, 0); - return (error); + return error; } memset(&zerocr, 0, sizeof(zerocr)); memset(&zeroino, 0, sizeof(zeroino)); @@ -1413,7 +1413,7 @@ xfs_qm_qino_alloc( &zerocr, 0, 1, ip, &committed))) { xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); - return (error); + return error; } /* @@ -1461,9 +1461,9 @@ xfs_qm_qino_alloc( if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL))) { xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!"); - return (error); + return error; } - return (0); + return 0; } @@ -1508,7 +1508,7 @@ xfs_qm_reset_dqcounts( ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); } - return (0); + return 0; } STATIC int @@ -1557,7 +1557,7 @@ xfs_qm_dqiter_bufs( bno++; firstid += XFS_QM_DQPERBLK(mp); } - return (error); + return error; } /* @@ -1586,7 +1586,7 @@ xfs_qm_dqiterate( * happens only at mount time which is single threaded. */ if (qip->i_d.di_nblocks == 0) - return (0); + return 0; map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP); @@ -1655,7 +1655,7 @@ xfs_qm_dqiterate( kmem_free(map, XFS_DQITER_MAP_SIZE * sizeof(*map)); - return (error); + return error; } /* @@ -1715,7 +1715,7 @@ xfs_qm_get_rtblks( ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); if (!(ifp->if_flags & XFS_IFEXTENTS)) { if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK))) - return (error); + return error; } rtblks = 0; nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t); @@ -1723,7 +1723,7 @@ xfs_qm_get_rtblks( for (ep = base; ep < &base[nextents]; ep++) rtblks += xfs_bmbt_get_blockcount(ep); *O_rtblks = (xfs_qcnt_t)rtblks; - return (0); + return 0; } /* @@ -1767,7 +1767,7 @@ xfs_qm_dqusage_adjust( */ if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) { *res = BULKSTAT_RV_NOTHING; - return (error); + return error; } if (ip->i_d.di_mode == 0) { @@ -1785,7 +1785,7 @@ xfs_qm_dqusage_adjust( if ((error = xfs_qm_dqget_noattach(ip, &udqp, &gdqp))) { xfs_iput(ip, XFS_ILOCK_EXCL); *res = BULKSTAT_RV_GIVEUP; - return (error); + return error; } rtblks = 0; @@ -1802,7 +1802,7 @@ xfs_qm_dqusage_adjust( if (gdqp) xfs_qm_dqput(gdqp); *res = BULKSTAT_RV_GIVEUP; - return (error); + return error; } nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks; } @@ -1847,7 +1847,7 @@ xfs_qm_dqusage_adjust( * Goto next inode. */ *res = BULKSTAT_RV_DIDONE; - return (0); + return 0; } /* @@ -2041,7 +2041,7 @@ xfs_qm_init_quotainos( XFS_QI_UQIP(mp) = uip; XFS_QI_GQIP(mp) = gip; - return (0); + return 0; } @@ -2062,7 +2062,7 @@ xfs_qm_shake_freelist( int nflushes; if (howmany <= 0) - return (0); + return 0; nreclaimed = 0; restarts = 0; @@ -2088,7 +2088,7 @@ xfs_qm_shake_freelist( xfs_dqunlock(dqp); xfs_qm_freelist_unlock(xfs_Gqm); if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) - return (nreclaimed); + return nreclaimed; XQM_STATS_INC(xqmstats.xs_qm_dqwants); goto tryagain; } @@ -2163,7 +2163,7 @@ xfs_qm_shake_freelist( XFS_DQ_HASH_UNLOCK(hash); xfs_qm_freelist_unlock(xfs_Gqm); if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) - return (nreclaimed); + return nreclaimed; goto tryagain; } xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); @@ -2188,7 +2188,7 @@ xfs_qm_shake_freelist( dqp = nextdqp; } xfs_qm_freelist_unlock(xfs_Gqm); - return (nreclaimed); + return nreclaimed; } @@ -2202,9 +2202,9 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask) int ndqused, nfree, n; if (!kmem_shake_allow(gfp_mask)) - return (0); + return 0; if (!xfs_Gqm) - return (0); + return 0; nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */ /* incore dquots in all f/s's */ @@ -2213,7 +2213,7 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask) ASSERT(ndqused >= 0); if (nfree <= ndqused && nfree < ndquot) - return (0); + return 0; ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */ n = nfree - ndqused - ndquot; /* # over target */ @@ -2257,7 +2257,7 @@ xfs_qm_dqreclaim_one(void) xfs_dqunlock(dqp); xfs_qm_freelist_unlock(xfs_Gqm); if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) - return (NULL); + return NULL; XQM_STATS_INC(xqmstats.xs_qm_dqwants); goto startagain; } @@ -2333,7 +2333,7 @@ xfs_qm_dqreclaim_one(void) } xfs_qm_freelist_unlock(xfs_Gqm); - return (dqpout); + return dqpout; } @@ -2369,7 +2369,7 @@ xfs_qm_dqalloc_incore( */ memset(&dqp->q_core, 0, sizeof(dqp->q_core)); *O_dqpp = dqp; - return (B_FALSE); + return B_FALSE; } XQM_STATS_INC(xqmstats.xs_qm_dqreclaim_misses); } @@ -2382,7 +2382,7 @@ xfs_qm_dqalloc_incore( *O_dqpp = kmem_zone_zalloc(xfs_Gqm->qm_dqzone, KM_SLEEP); atomic_inc(&xfs_Gqm->qm_totaldquots); - return (B_TRUE); + return B_TRUE; } @@ -2407,13 +2407,13 @@ xfs_qm_write_sb_changes( 0, XFS_DEFAULT_LOG_COUNT))) { xfs_trans_cancel(tp, 0); - return (error); + return error; } xfs_mod_sb(tp, flags); (void) xfs_trans_commit(tp, 0, NULL); - return (0); + return 0; } @@ -2463,7 +2463,7 @@ xfs_qm_vop_dqalloc( if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | XFS_QMOPT_ILOCKED))) { xfs_iunlock(ip, lockflags); - return (error); + return error; } } @@ -2486,7 +2486,7 @@ xfs_qm_vop_dqalloc( XFS_QMOPT_DOWARN, &uq))) { ASSERT(error != ENOENT); - return (error); + return error; } /* * Get the ilock in the right order. @@ -2517,7 +2517,7 @@ xfs_qm_vop_dqalloc( if (uq) xfs_qm_dqrele(uq); ASSERT(error != ENOENT); - return (error); + return error; } xfs_dqunlock(gq); lockflags = XFS_ILOCK_SHARED; @@ -2565,7 +2565,7 @@ xfs_qm_vop_dqalloc( *O_gdqpp = gq; else if (gq) xfs_qm_dqrele(gq); - return (0); + return 0; } /* @@ -2608,7 +2608,7 @@ xfs_qm_vop_chown( xfs_dqunlock(newdq); *IO_olddq = newdq; - return (prevdq); + return prevdq; } /* @@ -2702,12 +2702,12 @@ xfs_qm_vop_rename_dqattach( ip = i_tab[0]; if (! XFS_IS_QUOTA_ON(ip->i_mount)) - return (0); + return 0; if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { error = xfs_qm_dqattach(ip, 0); if (error) - return (error); + return error; } for (i = 1; (i < 4 && i_tab[i]); i++) { /* @@ -2717,11 +2717,11 @@ xfs_qm_vop_rename_dqattach( if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { error = xfs_qm_dqattach(ip, 0); if (error) - return (error); + return error; } } } - return (0); + return 0; } void @@ -2834,7 +2834,7 @@ xfs_qm_dqhashlock_nowait( int locked; locked = mutex_trylock(&((dqp)->q_hash->qh_lock)); - return (locked); + return locked; } int @@ -2844,7 +2844,7 @@ xfs_qm_freelist_lock_nowait( int locked; locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock)); - return (locked); + return locked; } STATIC int @@ -2855,5 +2855,5 @@ xfs_qm_mplist_nowait( ASSERT(mp->m_quotainfo); locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp))); - return (locked); + return locked; } diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index 950df31e..e830740 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c @@ -147,7 +147,7 @@ xfs_dir_shortform_create(xfs_da_args_t *args, xfs_ino_t parent) hdr->count = 0; dp->i_d.di_size = sizeof(*hdr); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); - return(0); + return 0; } /* @@ -180,7 +180,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) if (sfe->namelen == args->namelen && args->name[0] == sfe->name[0] && memcmp(args->name, sfe->name, args->namelen) == 0) - return(XFS_ERROR(EEXIST)); + return XFS_ERROR(EEXIST); sfe = XFS_DIR_SF_NEXTENTRY(sfe); } @@ -198,7 +198,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) dp->i_d.di_size += size; xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); - return(0); + return 0; } /* @@ -238,7 +238,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) } if (i < 0) { ASSERT(args->oknoent); - return(XFS_ERROR(ENOENT)); + return XFS_ERROR(ENOENT); } if ((base + size) != dp->i_d.di_size) { @@ -251,7 +251,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) dp->i_d.di_size -= size; xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); - return(0); + return 0; } /* @@ -390,7 +390,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs) out: kmem_free(tmpbuffer, size); - return(retval); + return retval; } STATIC int @@ -596,7 +596,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args) /* XXX - replace assert? */ XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sf->hdr.parent); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); - return(0); + return 0; } ASSERT(args->namelen != 1 || args->name[0] != '.'); sfe = &sf->list[0]; @@ -608,12 +608,12 @@ xfs_dir_shortform_replace(xfs_da_args_t *args) (char *)&sfe->inumber, sizeof(xfs_ino_t))); XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); - return(0); + return 0; } sfe = XFS_DIR_SF_NEXTENTRY(sfe); } ASSERT(args->oknoent); - return(XFS_ERROR(ENOENT)); + return XFS_ERROR(ENOENT); } /* @@ -695,7 +695,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) out: kmem_free(tmpbuffer, XFS_LBSIZE(dp->i_mount)); - return(retval); + return retval; } /* @@ -715,17 +715,17 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) retval = xfs_da_grow_inode(args, &blkno); ASSERT(blkno == 1); if (retval) - return(retval); + return retval; retval = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp1, XFS_DATA_FORK); if (retval) - return(retval); + return retval; ASSERT(bp1 != NULL); retval = xfs_da_get_buf(args->trans, args->dp, 1, -1, &bp2, XFS_DATA_FORK); if (retval) { xfs_da_buf_done(bp1); - return(retval); + return retval; } ASSERT(bp2 != NULL); memcpy(bp2->data, bp1->data, XFS_LBSIZE(dp->i_mount)); @@ -738,7 +738,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) retval = xfs_da_node_create(args, 0, 1, &bp1, XFS_DATA_FORK); if (retval) { xfs_da_buf_done(bp2); - return(retval); + return retval; } node = bp1->data; leaf = bp2->data; @@ -751,7 +751,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); xfs_da_buf_done(bp1); - return(retval); + return retval; } @@ -776,7 +776,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) ASSERT(dp != NULL); retval = xfs_da_get_buf(args->trans, dp, blkno, -1, &bp, XFS_DATA_FORK); if (retval) - return(retval); + return retval; ASSERT(bp != NULL); leaf = bp->data; memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); @@ -791,7 +791,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); *bpp = bp; - return(0); + return 0; } /* @@ -813,10 +813,10 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, ASSERT(oldblk->magic == XFS_DIR_LEAF_MAGIC); error = xfs_da_grow_inode(args, &blkno); if (error) - return(error); + return error; error = xfs_dir_leaf_create(args, blkno, &newblk->bp); if (error) - return(error); + return error; newblk->blkno = blkno; newblk->magic = XFS_DIR_LEAF_MAGIC; @@ -826,7 +826,7 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, xfs_dir_leaf_rebalance(state, oldblk, newblk); error = xfs_da_blk_link(state, oldblk, newblk); if (error) - return(error); + return error; /* * Insert the new entry in the correct block. @@ -842,7 +842,7 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, */ oldblk->hashval = xfs_dir_leaf_lasthash(oldblk->bp, NULL); newblk->hashval = xfs_dir_leaf_lasthash(newblk->bp, NULL); - return(error); + return error; } /* @@ -885,7 +885,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) if (INT_GET(map->size, ARCH_CONVERT) >= tmp) { if (!args->justcheck) xfs_dir_leaf_add_work(bp, args, index, i); - return(0); + return 0; } sum += INT_GET(map->size, ARCH_CONVERT); } @@ -896,7 +896,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) * no good and we should just give up. */ if (!hdr->holes && (sum < entsize)) - return(XFS_ERROR(ENOSPC)); + return XFS_ERROR(ENOSPC); /* * Compact the entries to coalesce free space. @@ -909,18 +909,18 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) (uint)sizeof(xfs_dir_leaf_entry_t) : 0, args->justcheck); if (error) - return(error); + return error; /* * After compaction, the block is guaranteed to have only one * free region, in freemap[0]. If it is not big enough, give up. */ if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT) < (entsize + (uint)sizeof(xfs_dir_leaf_entry_t))) - return(XFS_ERROR(ENOSPC)); + return XFS_ERROR(ENOSPC); if (!args->justcheck) xfs_dir_leaf_add_work(bp, args, index, 0); - return(0); + return 0; } /* @@ -1072,7 +1072,7 @@ xfs_dir_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp, int musthave, kmem_free(tmpbuffer, lbsize); if (musthave || justcheck) kmem_free(tmpbuffer2, lbsize); - return(rval); + return rval; } /* @@ -1292,7 +1292,7 @@ xfs_dir_leaf_figure_balance(xfs_da_state_t *state, *countarg = count; *namebytesarg = totallen; - return(foundit); + return foundit; } /*======================================================================== @@ -1334,7 +1334,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); if (bytes > (state->blocksize >> 1)) { *action = 0; /* blk over 50%, don't try to join */ - return(0); + return 0; } /* @@ -1353,13 +1353,13 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) error = xfs_da_path_shift(state, &state->altpath, forward, 0, &retval); if (error) - return(error); + return error; if (retval) { *action = 0; } else { *action = 2; } - return(0); + return 0; } /* @@ -1381,7 +1381,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) blkno, -1, &bp, XFS_DATA_FORK); if (error) - return(error); + return error; ASSERT(bp != NULL); leaf = (xfs_dir_leafblock_t *)info; @@ -1402,7 +1402,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) } if (i >= 2) { *action = 0; - return(0); + return 0; } xfs_da_buf_done(bp); @@ -1419,13 +1419,13 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) 0, &retval); } if (error) - return(error); + return error; if (retval) { *action = 0; } else { *action = 1; } - return(0); + return 0; } /* @@ -1575,8 +1575,8 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT) * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); tmp += INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); if (tmp < mp->m_dir_magicpct) - return(1); /* leaf is < 37% full */ - return(0); + return 1; /* leaf is < 37% full */ + return 0; } /* @@ -1732,7 +1732,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT)) || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { *index = probe; ASSERT(args->oknoent); - return(XFS_ERROR(ENOENT)); + return XFS_ERROR(ENOENT); } /* @@ -1745,14 +1745,14 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) memcmp(args->name, namest->name, args->namelen) == 0) { XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args->inumber); *index = probe; - return(XFS_ERROR(EEXIST)); + return XFS_ERROR(EEXIST); } entry++; probe++; } *index = probe; ASSERT(probe == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); - return(XFS_ERROR(ENOENT)); + return XFS_ERROR(ENOENT); } /*======================================================================== @@ -1890,9 +1890,9 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || (INT_GET(leaf2->entries[ INT_GET(leaf2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < INT_GET(leaf1->entries[ INT_GET(leaf1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { - return(1); + return 1; } - return(0); + return 0; } /* @@ -1942,7 +1942,7 @@ xfs_dir_leaf_getdents_int( leaf = bp->data; if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { *eobp = 1; - return(XFS_ERROR(ENOENT)); /* XXX wrong code */ + return XFS_ERROR(ENOENT); /* XXX wrong code */ } want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); @@ -2000,7 +2000,7 @@ xfs_dir_leaf_getdents_int( * the node code will be setting uio_offset anyway. */ *eobp = 0; - return(0); + return 0; } xfs_dir_trace_g_due("leaf: hash found", dp, uio, entry); @@ -2057,7 +2057,7 @@ xfs_dir_leaf_getdents_int( retval = xfs_da_read_buf(dp->i_transp, dp, thishash, nextda, &bp2, XFS_DATA_FORK); if (retval) - return(retval); + return retval; ASSERT(bp2 != NULL); @@ -2073,7 +2073,7 @@ xfs_dir_leaf_getdents_int( leaf2); xfs_da_brelse(dp->i_transp, bp2); - return(XFS_ERROR(EFSCORRUPTED)); + return XFS_ERROR(EFSCORRUPTED); } nexthash = INT_GET(leaf2->entries[0].hashval, @@ -2139,7 +2139,7 @@ xfs_dir_leaf_getdents_int( xfs_dir_trace_g_du("leaf: E-O-B", dp, uio); - return(retval); + return retval; } } @@ -2149,7 +2149,7 @@ xfs_dir_leaf_getdents_int( xfs_dir_trace_g_du("leaf: E-O-F", dp, uio); - return(0); + return 0; } /* diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 163031c..b4d971b 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -501,7 +501,7 @@ xfs_reserve_blocks( if (inval == (__uint64_t *)NULL) { outval->resblks = mp->m_resblks; outval->resblks_avail = mp->m_resblks_avail; - return(0); + return 0; } request = *inval; @@ -537,7 +537,7 @@ xfs_reserve_blocks( outval->resblks = mp->m_resblks; outval->resblks_avail = mp->m_resblks_avail; XFS_SB_UNLOCK(mp, s); - return(0); + return 0; } void diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 3d9a36e..9176995 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -403,7 +403,7 @@ xfs_log_release_iclog(xfs_mount_t *mp, if (xlog_state_release_iclog(log, iclog)) { xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); - return(EIO); + return EIO; } return 0; @@ -556,7 +556,7 @@ xfs_log_unmount(xfs_mount_t *mp) error = xfs_log_unmount_write(mp); xfs_log_unmount_dealloc(mp); - return (error); + return error; } /* @@ -728,7 +728,7 @@ xfs_log_write(xfs_mount_t * mp, if ((error = xlog_write(mp, reg, nentries, tic, start_lsn, NULL, 0))) { xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); } - return (error); + return error; } /* xfs_log_write */ @@ -836,7 +836,7 @@ xfs_log_need_covered(xfs_mount_t *mp) needed = 1; } LOG_UNLOCK(log, s); - return(needed); + return needed; } /****************************************************************************** @@ -1003,7 +1003,7 @@ xlog_bdstrat_cb(struct xfs_buf *bp) XFS_BUF_ERROR(bp, EIO); XFS_BUF_STALE(bp); xfs_biodone(bp); - return (XFS_ERROR(EIO)); + return XFS_ERROR(EIO); } @@ -1263,7 +1263,7 @@ xlog_commit_record(xfs_mount_t *mp, iclog, XLOG_COMMIT_TRANS))) { xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); } - return (error); + return error; } /* xlog_commit_record */ @@ -1460,7 +1460,7 @@ xlog_sync(xlog_t *log, if ((error = XFS_bwrite(bp))) { xfs_ioerror_alert("xlog_sync", log->l_mp, bp, XFS_BUF_ADDR(bp)); - return (error); + return error; } if (split) { bp = iclog->ic_log->l_xbuf; @@ -1498,10 +1498,10 @@ xlog_sync(xlog_t *log, if ((error = XFS_bwrite(bp))) { xfs_ioerror_alert("xlog_sync (split)", log->l_mp, bp, XFS_BUF_ADDR(bp)); - return (error); + return error; } } - return (0); + return 0; } /* xlog_sync */ @@ -1798,7 +1798,7 @@ xlog_write(xfs_mount_t * mp, for (index = 0; index < nentries; ) { if ((error = xlog_state_get_iclog_space(log, len, &iclog, ticket, &contwr, &log_offset))) - return (error); + return error; ASSERT(log_offset <= iclog->ic_size - 1); ptr = (__psint_t) ((char *)iclog->ic_datap+log_offset); @@ -1903,7 +1903,7 @@ xlog_write(xfs_mount_t * mp, xlog_state_finish_copy(log, iclog, record_cnt, data_cnt); record_cnt = data_cnt = 0; if ((error = xlog_state_release_iclog(log, iclog))) - return (error); + return error; break; /* don't increment index */ } else { /* copied entire region */ index++; @@ -1917,7 +1917,7 @@ xlog_write(xfs_mount_t * mp, ASSERT(flags & XLOG_COMMIT_TRANS); *commit_iclog = iclog; } else if ((error = xlog_state_release_iclog(log, iclog))) - return (error); + return error; if (index == nentries) return 0; /* we are done */ else @@ -1934,7 +1934,7 @@ xlog_write(xfs_mount_t * mp, *commit_iclog = iclog; return 0; } - return (xlog_state_release_iclog(log, iclog)); + return xlog_state_release_iclog(log, iclog); } /* xlog_write */ @@ -2050,7 +2050,7 @@ xlog_get_lowest_lsn( } lsn_log = lsn_log->ic_next; } while (lsn_log != log->l_iclog); - return(lowest_lsn); + return lowest_lsn; } @@ -2402,7 +2402,7 @@ restart: if (iclog->ic_refcnt == 1) { LOG_UNLOCK(log, s); if ((error = xlog_state_release_iclog(log, iclog))) - return (error); + return error; } else { iclog->ic_refcnt--; LOG_UNLOCK(log, s); @@ -2569,7 +2569,7 @@ xlog_regrant_write_log_space(xlog_t *log, XLOG_TIC_RESET_RES(tic); if (tic->t_cnt > 0) - return (0); + return 0; #ifdef DEBUG if (log->l_flags & XLOG_ACTIVE_RECOVERY) @@ -2667,7 +2667,7 @@ redo: xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit"); xlog_verify_grant_head(log, 1); GRANT_UNLOCK(log, s); - return (0); + return 0; error_return: @@ -2837,7 +2837,7 @@ xlog_state_release_iclog(xlog_t *log, if (sync) { return xlog_sync(log, iclog); } - return (0); + return 0; } /* xlog_state_release_iclog */ @@ -3127,7 +3127,7 @@ try_again: } while (iclog != log->l_iclog); LOG_UNLOCK(log, s); - return (0); + return 0; } /* xlog_state_sync */ @@ -3545,12 +3545,12 @@ xlog_state_ioerror( ic->ic_state = XLOG_STATE_IOERROR; ic = ic->ic_next; } while (ic != iclog); - return (0); + return 0; } /* * Return non-zero, if state transition has already happened. */ - return (1); + return 1; } /* @@ -3587,7 +3587,7 @@ xfs_log_force_umount( log->l_flags & XLOG_ACTIVE_RECOVERY) { mp->m_flags |= XFS_MOUNT_FS_SHUTDOWN; XFS_BUF_DONE(mp->m_sb_bp); - return (0); + return 0; } /* @@ -3596,7 +3596,7 @@ xfs_log_force_umount( */ if (logerror && log->l_iclog->ic_state & XLOG_STATE_IOERROR) { ASSERT(XLOG_FORCED_SHUTDOWN(log)); - return (1); + return 1; } retval = 0; /* @@ -3678,7 +3678,7 @@ xfs_log_force_umount( } #endif /* return non-zero if log IOERROR transition had already happened */ - return (retval); + return retval; } STATIC int @@ -3692,8 +3692,8 @@ xlog_iclogs_empty(xlog_t *log) * any language. */ if (iclog->ic_header.h_num_logops) - return(0); + return 0; iclog = iclog->ic_next; } while (iclog != log->l_iclog); - return(1); + return 1; } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 6088e14..62188ea 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -646,7 +646,7 @@ xfs_mountfs( if (mp->m_sb_bp == NULL) { if ((error = xfs_readsb(mp))) { - return (error); + return error; } } xfs_mount_common(mp, sbp); @@ -889,7 +889,7 @@ xfs_mountfs( * For client case we are done now */ if (mfsi_flags & XFS_MFSI_CLIENT) { - return(0); + return 0; } /* @@ -1182,7 +1182,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp) xfs_fs_cmn_err(CE_ALERT, mp, "Superblock write error detected while unmounting. Filesystem may not be marked shared readonly"); } xfs_buf_relse(sbp); - return (error); + return error; } /* @@ -1257,19 +1257,19 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field, lcounter += delta; if (lcounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_icount = lcounter; - return (0); + return 0; case XFS_SBS_IFREE: lcounter = (long long)mp->m_sb.sb_ifree; lcounter += delta; if (lcounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_ifree = lcounter; - return (0); + return 0; case XFS_SBS_FDBLOCKS: lcounter = (long long)mp->m_sb.sb_fdblocks; @@ -1296,101 +1296,101 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field, if (rsvd) { lcounter = (long long)mp->m_resblks_avail + delta; if (lcounter < 0) { - return (XFS_ERROR(ENOSPC)); + return XFS_ERROR(ENOSPC); } mp->m_resblks_avail = lcounter; - return (0); + return 0; } else { /* not reserved */ - return (XFS_ERROR(ENOSPC)); + return XFS_ERROR(ENOSPC); } } } mp->m_sb.sb_fdblocks = lcounter; - return (0); + return 0; case XFS_SBS_FREXTENTS: lcounter = (long long)mp->m_sb.sb_frextents; lcounter += delta; if (lcounter < 0) { - return (XFS_ERROR(ENOSPC)); + return XFS_ERROR(ENOSPC); } mp->m_sb.sb_frextents = lcounter; - return (0); + return 0; case XFS_SBS_DBLOCKS: lcounter = (long long)mp->m_sb.sb_dblocks; lcounter += delta; if (lcounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_dblocks = lcounter; - return (0); + return 0; case XFS_SBS_AGCOUNT: scounter = mp->m_sb.sb_agcount; scounter += delta; if (scounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_agcount = scounter; - return (0); + return 0; case XFS_SBS_IMAX_PCT: scounter = mp->m_sb.sb_imax_pct; scounter += delta; if (scounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_imax_pct = scounter; - return (0); + return 0; case XFS_SBS_REXTSIZE: scounter = mp->m_sb.sb_rextsize; scounter += delta; if (scounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_rextsize = scounter; - return (0); + return 0; case XFS_SBS_RBMBLOCKS: scounter = mp->m_sb.sb_rbmblocks; scounter += delta; if (scounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_rbmblocks = scounter; - return (0); + return 0; case XFS_SBS_RBLOCKS: lcounter = (long long)mp->m_sb.sb_rblocks; lcounter += delta; if (lcounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_rblocks = lcounter; - return (0); + return 0; case XFS_SBS_REXTENTS: lcounter = (long long)mp->m_sb.sb_rextents; lcounter += delta; if (lcounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_rextents = lcounter; - return (0); + return 0; case XFS_SBS_REXTSLOG: scounter = mp->m_sb.sb_rextslog; scounter += delta; if (scounter < 0) { ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } mp->m_sb.sb_rextslog = scounter; - return (0); + return 0; default: ASSERT(0); - return (XFS_ERROR(EINVAL)); + return XFS_ERROR(EINVAL); } } @@ -1409,7 +1409,7 @@ xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd) s = XFS_SB_LOCK(mp); status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); XFS_SB_UNLOCK(mp, s); - return (status); + return status; } /* @@ -1470,7 +1470,7 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd) } } XFS_SB_UNLOCK(mp, s); - return (status); + return status; } /* @@ -1500,7 +1500,7 @@ xfs_getsb( } XFS_BUF_HOLD(bp); ASSERT(XFS_BUF_ISDONE(bp)); - return (bp); + return bp; } /* diff --git a/fs/xfs/xfs_trans_item.c b/fs/xfs/xfs_trans_item.c index 486147e..1117d60 100644 --- a/fs/xfs/xfs_trans_item.c +++ b/fs/xfs/xfs_trans_item.c @@ -78,7 +78,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip) lidp->lid_size = 0; lip->li_desc = lidp; lip->li_mountp = tp->t_mountp; - return (lidp); + return lidp; } /* @@ -119,7 +119,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip) lidp->lid_size = 0; lip->li_desc = lidp; lip->li_mountp = tp->t_mountp; - return (lidp); + return lidp; } /* @@ -180,7 +180,7 @@ xfs_trans_find_item(xfs_trans_t *tp, xfs_log_item_t *lip) { ASSERT(lip->li_desc != NULL); - return (lip->li_desc); + return lip->li_desc; } @@ -219,10 +219,10 @@ xfs_trans_first_item(xfs_trans_t *tp) continue; } - return (XFS_LIC_SLOT(licp, i)); + return XFS_LIC_SLOT(licp, i); } cmn_err(CE_WARN, "xfs_trans_first_item() -- no first item"); - return(NULL); + return NULL; } @@ -252,7 +252,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp) continue; } - return (XFS_LIC_SLOT(licp, i)); + return XFS_LIC_SLOT(licp, i); } /* @@ -261,7 +261,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp) * If there is no next chunk, return NULL. */ if (licp->lic_next == NULL) { - return (NULL); + return NULL; } licp = licp->lic_next; @@ -271,7 +271,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp) continue; } - return (XFS_LIC_SLOT(licp, i)); + return XFS_LIC_SLOT(licp, i); } ASSERT(0); /* NOTREACHED */ @@ -425,7 +425,7 @@ xfs_trans_unlock_chunk( } } - return (freed); + return freed; } @@ -478,7 +478,7 @@ xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx) */ lbsp->lbc_ag = ag; lbsp->lbc_idx = idx; - return (lbsp); + return lbsp; } /* @@ -512,7 +512,7 @@ xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx) tp->t_busy_free--; lbsp->lbc_ag = ag; lbsp->lbc_idx = idx; - return (lbsp); + return lbsp; } diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 8076cc9..eaab355 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c @@ -338,7 +338,7 @@ xfs_setattr( code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, projid, qflags, &udqp, &gdqp); if (code) - return (code); + return code; } /* @@ -1027,11 +1027,8 @@ xfs_readlink( } - error_return: - xfs_iunlock(ip, XFS_ILOCK_SHARED); - return error; } @@ -1206,7 +1203,7 @@ xfs_inactive_free_eofblocks( last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); map_len = last_fsb - end_fsb; if (map_len <= 0) - return (0); + return 0; nimaps = 1; xfs_ilock(ip, XFS_ILOCK_SHARED); @@ -1221,7 +1218,7 @@ xfs_inactive_free_eofblocks( * Attach the dquots to the inode up front. */ if ((error = XFS_QM_DQATTACH(mp, ip, 0))) - return (error); + return error; /* * There are blocks after the end of file. @@ -1249,7 +1246,7 @@ xfs_inactive_free_eofblocks( ASSERT(XFS_FORCED_SHUTDOWN(mp)); xfs_trans_cancel(tp, 0); xfs_iunlock(ip, XFS_IOLOCK_EXCL); - return (error); + return error; } xfs_ilock(ip, XFS_ILOCK_EXCL); @@ -1277,7 +1274,7 @@ xfs_inactive_free_eofblocks( } xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); } - return (error); + return error; } /* @@ -1455,7 +1452,7 @@ xfs_inactive_symlink_local( if (error) { xfs_trans_cancel(*tpp, 0); *tpp = NULL; - return (error); + return error; } xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); @@ -1468,7 +1465,7 @@ xfs_inactive_symlink_local( XFS_DATA_FORK); ASSERT(ip->i_df.if_bytes == 0); } - return (0); + return 0; } /* @@ -1494,7 +1491,7 @@ xfs_inactive_attrs( if (error) { *tpp = NULL; xfs_iunlock(ip, XFS_IOLOCK_EXCL); - return (error); /* goto out*/ + return error; /* goto out */ } tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); @@ -1507,7 +1504,7 @@ xfs_inactive_attrs( xfs_trans_cancel(tp, 0); *tpp = NULL; xfs_iunlock(ip, XFS_IOLOCK_EXCL); - return (error); + return error; } xfs_ilock(ip, XFS_ILOCK_EXCL); @@ -1518,7 +1515,7 @@ xfs_inactive_attrs( ASSERT(ip->i_d.di_anextents == 0); *tpp = tp; - return (0); + return 0; } STATIC int @@ -1557,7 +1554,7 @@ xfs_release( (!(ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) { if ((error = xfs_inactive_free_eofblocks(mp, ip))) - return (error); + return error; /* Update linux inode block count after free above */ LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks); @@ -1638,7 +1635,7 @@ xfs_inactive( (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || (ip->i_delayed_blks != 0)))) { if ((error = xfs_inactive_free_eofblocks(mp, ip))) - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; /* Update linux inode block count after free above */ LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks); @@ -1649,7 +1646,7 @@ xfs_inactive( ASSERT(ip->i_d.di_nlink == 0); if ((error = XFS_QM_DQATTACH(mp, ip, 0))) - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); if (truncate) { @@ -1672,7 +1669,7 @@ xfs_inactive( ASSERT(XFS_FORCED_SHUTDOWN(mp)); xfs_trans_cancel(tp, 0); xfs_iunlock(ip, XFS_IOLOCK_EXCL); - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; } xfs_ilock(ip, XFS_ILOCK_EXCL); @@ -1693,7 +1690,7 @@ xfs_inactive( xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; } } else if ((ip->i_d.di_mode & S_IFMT) == S_IFLNK) { @@ -1707,7 +1704,7 @@ xfs_inactive( if (error) { ASSERT(tp == NULL); - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; } xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); @@ -1720,7 +1717,7 @@ xfs_inactive( if (error) { ASSERT(XFS_FORCED_SHUTDOWN(mp)); xfs_trans_cancel(tp, 0); - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; } xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); @@ -1742,7 +1739,7 @@ xfs_inactive( * cancelled, and the inode is unlocked. Just get out. */ if (error) - return (VN_INACTIVE_CACHE); + return VN_INACTIVE_CACHE; } else if (ip->i_afp) { xfs_idestroy_fork(ip, XFS_ATTR_FORK); } @@ -2049,8 +2046,8 @@ std_return: abort_return: cancel_flags |= XFS_TRANS_ABORT; /* FALLTHROUGH */ - error_return: + error_return: if (tp != NULL) xfs_trans_cancel(tp, cancel_flags); @@ -2724,9 +2721,9 @@ std_return: abort_return: cancel_flags |= XFS_TRANS_ABORT; /* FALLTHROUGH */ + error_return: xfs_trans_cancel(tp, cancel_flags); - goto std_return; } /* @@ -3199,10 +3196,12 @@ std_return: } return error; - error1: +error1: xfs_bmap_cancel(&free_list); cancel_flags |= XFS_TRANS_ABORT; - error_return: + /* FALLTHROUGH */ + +error_return: xfs_trans_cancel(tp, cancel_flags); goto std_return; } @@ -3618,9 +3617,9 @@ xfs_rwlock( if (locktype == VRWLOCK_WRITE) { xfs_ilock(ip, XFS_IOLOCK_EXCL); } else if (locktype == VRWLOCK_TRY_READ) { - return (xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)); + return xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED); } else if (locktype == VRWLOCK_TRY_WRITE) { - return (xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)); + return xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL); } else { ASSERT((locktype == VRWLOCK_READ) || (locktype == VRWLOCK_WRITE_DIRECT)); @@ -3868,7 +3867,7 @@ xfs_finish_reclaim( xfs_ifunlock(ip); xfs_iunlock(ip, XFS_ILOCK_EXCL); } - return(1); + return 1; } ip->i_flags |= XFS_IRECLAIM; write_unlock(&ih->ih_lock); @@ -4045,7 +4044,7 @@ xfs_alloc_file_space( offset, end_dmi_offset - offset, 0, NULL); if (error) - return(error); + return error; } /* @@ -4305,7 +4304,7 @@ xfs_free_file_space( offset, end_dmi_offset - offset, AT_DELAY_FLAG(attr_flags), NULL); if (error) - return(error); + return error; } ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1); |