CVS: intermezzo/fs25 cache.c,1.2,1.3 dcache.c,1.1,1.2 dir.c,1.3,1.4 ext_attr.c,1.1,1.2 file.c,1.1,1.2 fileset.c,1.2,1.3 inode.c,1.2,1.3 journal.c,1.2,1.3 kml_reint.c,1.1,1.2 methods.c,1.2,1.3 replicator.c,1.1,1.2 super.c,1.5,1.6 sysctl.c,1.2,1.3
Chen Yang <[email protected]> Wed, 25 Jun 2003 23:14:46 -0700
| Newsgroups | gmane.comp.file-systems.intermezzo.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/intermezzo/intermezzo/fs25 In directory sc8-pr-cvs1:/tmp/cvs-serv21075/intermezzo/fs25 Modified Files: cache.c dcache.c dir.c ext_attr.c file.c fileset.c inode.c journal.c kml_reint.c methods.c replicator.c super.c sysctl.c Log Message: From: [email protected] intermezzo stack lossage From: Adrian Bunk <[email protected]> Removed obsolete __NO_VERSION__ Index: cache.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/cache.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- cache.c 11 Oct 2002 23:29:57 -0000 1.2 +++ cache.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -21,5 +21,4 @@ */ -#define __NO_VERSION__ #include <linux/module.h> #include <stdarg.h> Index: dcache.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/dcache.c,v retrieving revision 1.1 retrieving revision 1.2 diff -U2 -r1.1 -r1.2 --- dcache.c 11 Oct 2002 22:52:01 -0000 1.1 +++ dcache.c 26 Jun 2003 06:14:43 -0000 1.2 @@ -32,5 +32,4 @@ */ -#define __NO_VERSION__ #include <linux/types.h> #include <linux/kernel.h> Index: dir.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/dir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -U2 -r1.3 -r1.4 --- dir.c 12 Oct 2002 02:16:19 -0000 1.3 +++ dir.c 26 Jun 2003 06:14:43 -0000 1.4 @@ -43,5 +43,4 @@ #include <linux/blkdev.h> #include <linux/init.h> -#define __NO_VERSION__ #include <linux/module.h> @@ -881,8 +880,9 @@ unsigned int cmd, unsigned long arg) { - char buf[1024]; struct izo_ioctl_data *data = NULL; struct presto_dentry_data *dd; int rc; + char* buf; + static const size_t bufsz = 1024; ENTRY; @@ -891,5 +891,6 @@ dd = presto_d2d(file->f_dentry); if (dd && dd->dd_fset) { - int (*cache_ioctl)(struct inode *, struct file *, unsigned int, unsigned long ) = filter_c2cdfops(dd->dd_fset->fset_cache->cache_filter)->ioctl; + int (*cache_ioctl)(struct inode *, struct file *, unsigned int, unsigned long); + cache_ioctl = filter_c2cdfops(dd->dd_fset->fset_cache->cache_filter)->ioctl; rc = -ENOTTY; if (cache_ioctl) @@ -906,9 +907,15 @@ } - memset(buf, 0, sizeof(buf)); - - if (izo_ioctl_getdata(buf, buf + 1024, (void *)arg)) { + /* allocate a zero'd buffer for data */ + PRESTO_ALLOC(buf, bufsz); + if (!buf) { + EXIT; + return -ENOMEM; + } + + if (izo_ioctl_getdata(buf, buf + bufsz, (void *)arg)) { CERROR("intermezzo ioctl: data error\n"); - return -EINVAL; + rc = -EINVAL; + goto done; } data = (struct izo_ioctl_data *)buf; @@ -916,9 +923,7 @@ switch(cmd) { case IZO_IOC_REINTKML: { - int rc; int cperr; rc = kml_reint_rec(file, data); - EXIT; cperr = copy_to_user((char *)arg, data, sizeof(*data)); if (cperr) { @@ -926,5 +931,5 @@ rc = -EFAULT; } - return rc; + goto done; } @@ -932,19 +937,17 @@ struct izo_rcvd_rec rec; struct presto_file_set *fset; - int rc; fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; - } + rc = -ENODEV; + goto done; + } + rc = izo_rcvd_get(&rec, fset, data->ioc_uuid); - if (rc < 0) { - EXIT; - return rc; - } + if (rc < 0) + goto done; - EXIT; - return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0; + rc = copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0; + goto done; } @@ -955,10 +958,9 @@ struct presto_file_set *fset; int minor; - int rc; fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -969,11 +971,9 @@ rc = izo_repstatus(fset, client_kmlsize, lr_client, &rec); - if (rc < 0) { - EXIT; - return rc; - } + if (rc < 0) + goto done; - EXIT; - return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0; + rc = copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0; + goto done; } @@ -983,28 +983,26 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } data->ioc_dev = fset->fset_cache->cache_psdev->uc_minor; CDEBUG(D_PSDEV, "CHANNEL %d\n", data->ioc_dev); - EXIT; - return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + rc = copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; } case IZO_IOC_SET_IOCTL_UID: izo_authorized_uid = data->ioc_uid; - EXIT; - return 0; + rc = 0; + goto done; case IZO_IOC_SET_PID: rc = izo_psdev_setpid(data->ioc_dev); - EXIT; - return rc; + goto done; case IZO_IOC_SET_CHANNEL: rc = izo_psdev_setchannel(file, data->ioc_dev); - EXIT; - return rc; + goto done; case IZO_IOC_GET_KML_SIZE: { @@ -1014,12 +1012,12 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } kmlsize = presto_kml_offset(fset) + fset->fset_kml_logical_off; - EXIT; - return copy_to_user((char *)arg, &kmlsize, sizeof(kmlsize))?-EFAULT : 0; + rc = copy_to_user((char *)arg, &kmlsize, sizeof(kmlsize))?-EFAULT : 0; + goto done; } @@ -1029,27 +1027,28 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } rc = izo_purge_file(fset, data->ioc_inlbuf1); - EXIT; - return rc; + goto done; } case IZO_IOC_GET_FILEID: { rc = izo_get_fileid(file, data); - EXIT; if (rc) - return rc; - return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; + + rc = copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; } case IZO_IOC_SET_FILEID: { rc = izo_set_fileid(file, data); - EXIT; if (rc) - return rc; - return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; + + rc = copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; } @@ -1058,6 +1057,5 @@ info = (struct lento_vfs_context *)data->ioc_inlbuf1; rc = presto_adjust_lml(file, info); - EXIT; - return rc; + goto done; } @@ -1068,6 +1066,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1076,6 +1074,5 @@ data->ioc_generation, data->ioc_uuid, data->ioc_flags); - EXIT; - return rc; + goto done; } @@ -1086,6 +1083,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1093,6 +1090,5 @@ rc = izo_upc_go_fetch_kml(minor, fset->fset_name, data->ioc_uuid, data->ioc_kmlsize); - EXIT; - return rc; + goto done; } @@ -1102,11 +1098,9 @@ else rc = izo_revoke_permit(file->f_dentry, NULL); - EXIT; - return rc; + goto done; case IZO_IOC_CLEAR_FSET: rc = izo_clear_fsetroot(file->f_dentry); - EXIT; - return rc; + goto done; case IZO_IOC_CLEAR_ALL_FSETS: { @@ -1115,11 +1109,10 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } rc = izo_clear_all_fsetroots(fset->fset_cache); - EXIT; - return rc; + goto done; } @@ -1131,7 +1124,5 @@ data->ioc_inlbuf1, data->ioc_flags); - EXIT; - return rc; - + goto done; case IZO_IOC_MARK: { @@ -1189,6 +1180,6 @@ if (error) { - EXIT; - return error; + rc = error; + goto done; } data->ioc_mark_what = res; @@ -1197,6 +1188,6 @@ data->ioc_or_flag, data->ioc_mark_what); - EXIT; - return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + rc = copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0; + goto done; } #if 0 @@ -1207,6 +1198,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1215,6 +1206,5 @@ data->ioc_inlbuf1, data->ioc_inlbuf2); - EXIT; - return rc; + goto done; } #endif @@ -1225,12 +1215,12 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); izo_upc_server_make_branch(minor, data->ioc_inlbuf1); - EXIT; - return 0; + rc = 0; + goto done; } case IZO_IOC_SET_KMLSIZE: { @@ -1241,6 +1231,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1249,8 +1239,6 @@ data->ioc_kmlsize); - if (rc != 0) { - EXIT; - return rc; - } + if (rc != 0) + goto done; rc = izo_rcvd_get(&rec, fset, data->ioc_uuid); @@ -1259,8 +1247,7 @@ * worries. */ memset(&rec, 0, sizeof(rec)); - } else if (rc <= 0) { + } else if (rc <= 0) { /* do we really want to return 0 if rc == 0 here? */ CERROR("InterMezzo: error reading last_rcvd: %d\n", rc); - EXIT; - return rc; + goto done; } rec.lr_remote_offset = data->ioc_kmlsize; @@ -1268,9 +1255,7 @@ if (rc <= 0) { CERROR("InterMezzo: error writing last_rcvd: %d\n", rc); - EXIT; - return rc; + goto done; } - EXIT; - return rc; + goto done; } case IZO_IOC_BRANCH_UNDO: { @@ -1280,6 +1265,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1287,6 +1272,5 @@ rc = izo_upc_branch_undo(minor, fset->fset_name, data->ioc_inlbuf1); - EXIT; - return rc; + goto done; } case IZO_IOC_BRANCH_REDO: { @@ -1296,6 +1280,6 @@ fset = presto_fset(file->f_dentry); if (fset == NULL) { - EXIT; - return -ENODEV; + rc = -ENODEV; + goto done; } minor = presto_f2m(fset); @@ -1303,19 +1287,24 @@ rc = izo_upc_branch_redo(minor, fset->fset_name, data->ioc_inlbuf1); - EXIT; - return rc; + goto done; } case TCGETS: - EXIT; - return -EINVAL; + rc = -EINVAL; + goto done; default: EXIT; - return -EINVAL; - + rc = -EINVAL; + goto done; + } + + rc = 0; + + done: + PRESTO_FREE(buf, bufsz); EXIT; - return 0; + return rc; } Index: ext_attr.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/ext_attr.c,v retrieving revision 1.1 retrieving revision 1.2 diff -U2 -r1.1 -r1.2 --- ext_attr.c 11 Oct 2002 22:52:01 -0000 1.1 +++ ext_attr.c 26 Jun 2003 06:14:43 -0000 1.2 @@ -23,5 +23,4 @@ */ -#define __NO_VERSION__ #include <linux/module.h> #include <linux/kernel.h> Index: file.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/file.c,v retrieving revision 1.1 retrieving revision 1.2 diff -U2 -r1.1 -r1.2 --- file.c 11 Oct 2002 22:52:01 -0000 1.1 +++ file.c 26 Jun 2003 06:14:43 -0000 1.2 @@ -48,5 +48,4 @@ #include <linux/init.h> #include <linux/smp_lock.h> -#define __NO_VERSION__ #include <linux/module.h> Index: fileset.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/fileset.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- fileset.c 11 Oct 2002 23:39:01 -0000 1.2 +++ fileset.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -23,5 +23,4 @@ */ -#define __NO_VERSION__ #include <stdarg.h> Index: inode.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/inode.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- inode.c 12 Oct 2002 00:10:14 -0000 1.2 +++ inode.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -25,5 +25,4 @@ */ -#define __NO_VERSION__ #include <linux/module.h> #include <linux/kernel.h> Index: journal.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/journal.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- journal.c 11 Oct 2002 23:39:01 -0000 1.2 +++ journal.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -1235,4 +1235,6 @@ } +/* we are called from presto_finish_kml_truncate, which is called */ +/* with fset->fset_kml.fd_lock held. Allocations must be GFP_ATOMIC */ struct file * presto_copy_kml_tail(struct presto_file_set *fset, unsigned long int start) @@ -1241,4 +1243,6 @@ int len; loff_t read_off, write_off, bytes; + char* buf; + size_t bufsz; ENTRY; @@ -1254,14 +1258,22 @@ read_off = start; bytes = fset->fset_kml.fd_offset - start; - while (bytes > 0) { - char buf[4096]; - int toread; - if (bytes > sizeof(buf)) - toread = sizeof(buf); - else - toread = bytes; + bufsz = bytes; + /* can't use PRESTO_ALLOC - alloction must be atomic */ + buf = kmalloc(bufsz, GFP_ATOMIC); + if (!buf) { + CERROR("IZO: out of memory at %s:%d (trying to " + "allocate %d)\n", __FILE__, __LINE__, + bufsz); + filp_close(f, NULL); + EXIT; + return ERR_PTR(-ENOMEM); + } + + presto_kmem_inc(buf, bufsz); + memset(buf, 0, bufsz); - len = presto_fread(fset->fset_kml.fd_file, buf, toread, + while (bytes > 0) { + len = presto_fread(fset->fset_kml.fd_file, buf, bufsz, &read_off); if (len <= 0) @@ -1269,4 +1281,6 @@ if (presto_fwrite(f, buf, len, &write_off) != len) { + kfree(buf); + presto_kmem_dec(buf, bufsz); filp_close(f, NULL); EXIT; @@ -1276,5 +1290,7 @@ bytes -= len; } - + + kfree(buf); + presto_kmem_dec(buf, bufsz); EXIT; return f; @@ -1585,9 +1601,10 @@ int opcode = KML_OPCODE_GET_FILEID; struct rec_info rec; - char *buffer, *path, *logrecord, record[4096]; /*include path*/ + char *buffer, *path, *logrecord, *record; /*include path*/ struct dentry *root; __u32 uid, gid, pathlen; int error, size; struct kml_suffix *suffix; + size_t record_size; ENTRY; @@ -1605,7 +1622,11 @@ sizeof(struct kml_suffix); + record_size = max(4096, size); + error = -ENOMEM; + PRESTO_ALLOC(record, record_size); + if (!record) + goto free_buffer; + CDEBUG(D_FILE, "kml size: %d\n", size); - if ( size > sizeof(record) ) - CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__); memset(&rec, 0, sizeof(rec)); @@ -1628,4 +1649,7 @@ fset->fset_name); + PRESTO_FREE(record, record_size); + + free_buffer: BUFF_FREE(buffer); EXIT; Index: kml_reint.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/kml_reint.c,v retrieving revision 1.1 retrieving revision 1.2 diff -U2 -r1.1 -r1.2 --- kml_reint.c 11 Oct 2002 22:52:01 -0000 1.1 +++ kml_reint.c 26 Jun 2003 06:14:43 -0000 1.2 @@ -23,5 +23,4 @@ */ -#define __NO_VERSION__ #include <linux/module.h> #include <linux/errno.h> Index: methods.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/methods.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- methods.c 21 Apr 2003 16:23:08 -0000 1.2 +++ methods.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -43,5 +43,4 @@ #include <linux/blkdev.h> #include <linux/init.h> -#define __NO_VERSION__ #include <linux/module.h> Index: replicator.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/replicator.c,v retrieving revision 1.1 retrieving revision 1.2 diff -U2 -r1.1 -r1.2 --- replicator.c 11 Oct 2002 22:52:01 -0000 1.1 +++ replicator.c 26 Jun 2003 06:14:43 -0000 1.2 @@ -24,5 +24,4 @@ */ -#define __NO_VERSION__ #include <linux/module.h> #include <stdarg.h> Index: super.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/super.c,v retrieving revision 1.5 retrieving revision 1.6 diff -U2 -r1.5 -r1.6 --- super.c 26 Feb 2003 06:14:03 -0000 1.5 +++ super.c 26 Jun 2003 06:14:43 -0000 1.6 @@ -45,5 +45,4 @@ #include <linux/init.h> #include <linux/devfs_fs_kernel.h> -#define __NO_VERSION__ #include <linux/module.h> Index: sysctl.c =================================================================== RCS file: /cvsroot/intermezzo/intermezzo/fs25/sysctl.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U2 -r1.2 -r1.3 --- sysctl.c 12 Oct 2002 05:45:51 -0000 1.2 +++ sysctl.c 26 Jun 2003 06:14:43 -0000 1.3 @@ -22,5 +22,4 @@ */ -#define __NO_VERSION__ #include <linux/config.h> /* for CONFIG_PROC_FS */ #include <linux/module.h> ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php