Showing block size added to /proc/scsi_tgt/disk_fileio/disk_fileio
[mirror/scst/.git] / scst / src / dev_handlers / scst_fileio.c
index 58f7a04..d78d0b2 100644 (file)
@@ -700,8 +700,6 @@ static int fileio_attach_tgt(struct scst_tgt_dev *tgt_dev)
        TRACE_ENTRY();
 
        ftgt_dev = kzalloc(sizeof(*ftgt_dev), GFP_KERNEL);
-       TRACE_MEM("kzalloc(GFP_KERNEL) for ftgt_dev (%zd): %p", 
-               sizeof(*ftgt_dev), ftgt_dev);
        if (ftgt_dev == NULL) {
                TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of per-session "
                        "virtual device failed");
@@ -755,7 +753,6 @@ out_free_close:
                filp_close(ftgt_dev->fd, NULL);
 
 out_free:
-       TRACE_MEM("kfree ftgt_dev: %p", ftgt_dev);
        kfree(ftgt_dev);
        goto out;
 }
@@ -780,12 +777,9 @@ static void fileio_detach_tgt(struct scst_tgt_dev *tgt_dev)
        if (ftgt_dev->fd)
                filp_close(ftgt_dev->fd, NULL);
 
-       if (ftgt_dev->iv != NULL) {
-               TRACE_MEM("kfree ftgt_dev->iv: %p", ftgt_dev->iv);
+       if (ftgt_dev->iv != NULL)
                kfree(ftgt_dev->iv);
-       }
 
-       TRACE_MEM("kfree ftgt_dev: %p", ftgt_dev);
        kfree(ftgt_dev);
 
        tgt_dev->dh_priv = NULL;
@@ -1725,7 +1719,7 @@ static void fileio_exec_read_capacity16(struct scst_cmd *cmd)
        nblocks = virt_dev->nblocks;
 
        memset(buffer, 0, sizeof(buffer));
-       data64 = (uint64_t *)buffer;
+       data64 = (uint64_t*)buffer;
        data64[0] = cpu_to_be64(nblocks - 1);
        buffer[8] = (blocksize >> (BYTE * 3)) & 0xFF;
        buffer[9] = (blocksize >> (BYTE * 2)) & 0xFF;
@@ -1892,13 +1886,9 @@ static struct iovec *fileio_alloc_iv(struct scst_cmd *cmd,
        
        iv_count = scst_get_buf_count(cmd);
        if (iv_count > ftgt_dev->iv_count) {
-               if (ftgt_dev->iv != NULL) {
-                       TRACE_MEM("kfree ftgt_dev->iv: %p", ftgt_dev->iv);
+               if (ftgt_dev->iv != NULL)
                        kfree(ftgt_dev->iv);
-               }
                ftgt_dev->iv = kmalloc(sizeof(*ftgt_dev->iv) * iv_count, GFP_KERNEL);
-               TRACE_MEM("kmalloc(GFP_KERNEL) for iv (%zd): %p",
-                   sizeof(*ftgt_dev->iv) * iv_count, ftgt_dev->iv);
                if (ftgt_dev->iv == NULL) {
                        PRINT_ERROR_PR("Unable to allocate iv (%d)", iv_count);
                        scst_set_busy(cmd);
@@ -2260,7 +2250,6 @@ static inline struct scst_fileio_dev *fileio_alloc_dev(void)
 {
        struct scst_fileio_dev *dev;
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       TRACE_MEM("kzalloc(GFP_KERNEL) for dev (%zd): %p", sizeof(*dev), dev);
        if (dev == NULL) {
                TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of virtual "
                        "device failed");
@@ -2312,8 +2301,8 @@ static int disk_fileio_proc(char *buffer, char **start, off_t offset,
        }
        
        if (inout == 0) { /* read */
-               size = scnprintf(buffer, length, "%-17s %-12s %-15s %s\n",
-                              "Name", "Size(MB)", "Options", "File name");
+               size = scnprintf(buffer, length, "%-17s %-11s %-11s %-15s %s\n",
+                              "Name", "Size(MB)", "Block size", "Options", "File name");
                if (fileio_proc_update_size(size, &len, &begin, &pos, &offset)) {
                        res = len;
                        goto out_up;
@@ -2324,8 +2313,9 @@ static int disk_fileio_proc(char *buffer, char **start, off_t offset,
                {
                        int c;
                        size = scnprintf(buffer + len, length - len, 
-                               "%-17s %-13d", virt_dev->name,
-                               (uint32_t)(virt_dev->file_size >> 20));
+                               "%-17s %-11d %-12d", virt_dev->name,
+                               (uint32_t)(virt_dev->file_size >> 20),
+                               virt_dev->block_size);
                        if (fileio_proc_update_size(size, &len, &begin, &pos, 
                                                &offset)) {
                                res = len;
@@ -2551,8 +2541,6 @@ static int disk_fileio_proc(char *buffer, char **start, off_t offset,
 
                        len = strlen(file_name) + 1;
                        virt_dev->file_name = kmalloc(len, GFP_KERNEL);
-                       TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p",
-                                 len, virt_dev->file_name);
                        if (virt_dev->file_name == NULL) {
                                TRACE(TRACE_OUT_OF_MEM, "%s",
                                      "Allocation of file_name failed");
@@ -2598,9 +2586,7 @@ static int disk_fileio_proc(char *buffer, char **start, off_t offset,
 
                        list_del(&virt_dev->fileio_dev_list_entry);
 
-                       TRACE_MEM("kfree for file_name: %p", virt_dev->file_name);
                        kfree(virt_dev->file_name);
-                       TRACE_MEM("kfree for virt_dev: %p", virt_dev);
                        kfree(virt_dev);
                }
                res = length;
@@ -2615,12 +2601,9 @@ out:
 
 out_free_vpath:
        list_del(&virt_dev->fileio_dev_list_entry);
-
-       TRACE_MEM("kfree for file_name: %p", virt_dev->file_name);
        kfree(virt_dev->file_name);
 
 out_free_vdev:
-       TRACE_MEM("kfree for virt_dev: %p", virt_dev);
        kfree(virt_dev);
        goto out_up;
 }
@@ -2681,8 +2664,6 @@ static int cdrom_fileio_open(char *p, char *name)
        if (!virt_dev->cdrom_empty) {
                len = strlen(file_name) + 1;
                virt_dev->file_name = kmalloc(len, GFP_KERNEL);
-               TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p",
-                         len, virt_dev->file_name);
                if (virt_dev->file_name == NULL) {
                        TRACE(TRACE_OUT_OF_MEM, "%s",
                              "Allocation of file_name failed");
@@ -2711,12 +2692,9 @@ out:
 
 out_free_vpath:
        list_del(&virt_dev->fileio_dev_list_entry);
-
-       TRACE_MEM("kfree for file_name: %p", virt_dev->file_name);
        kfree(virt_dev->file_name);
 
 out_free_vdev:
-       TRACE_MEM("kfree for virt_dev: %p", virt_dev);
        kfree(virt_dev);
        goto out;
 }
@@ -2749,11 +2727,8 @@ static int cdrom_fileio_close(char *name)
 
        list_del(&virt_dev->fileio_dev_list_entry);
 
-       if (virt_dev->file_name) {
-               TRACE_MEM("kfree for file_name: %p", virt_dev->file_name);
+       if (virt_dev->file_name)
                kfree(virt_dev->file_name);
-       }
-       TRACE_MEM("kfree for virt_dev: %p", virt_dev);
        kfree(virt_dev);
 
 out:
@@ -2810,8 +2785,6 @@ static int cdrom_fileio_change(char *p, char *name)
        if (!virt_dev->cdrom_empty) {
                len = strlen(file_name) + 1;
                fn = kmalloc(len, GFP_KERNEL);
-               TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p",
-                       len, fn);
                if (fn == NULL) {
                        TRACE(TRACE_OUT_OF_MEM, "%s",
                                "Allocation of file_name failed");
@@ -2908,10 +2881,8 @@ static int cdrom_fileio_change(char *p, char *name)
                        virt_dev->name);
        }
 
-       if (old_fn) {
-               TRACE_MEM("kfree for old_fn: %p", old_fn);
+       if (old_fn)
                kfree(old_fn);
-       }
 
 out_resume:
        scst_resume_activity();
@@ -2921,19 +2892,16 @@ out:
 
 out_free:
        virt_dev->file_name = old_fn;
-       TRACE_MEM("kfree for fn: %p", fn);
        kfree(fn);
        goto out;
 
 out_free_resume:
        virt_dev->file_name = old_fn;
-       TRACE_MEM("kfree for fn: %p", fn);
        kfree(fn);
        goto out_resume;
 
 out_err_resume:
        virt_dev->file_name = old_fn;
-       TRACE_MEM("kfree for fn: %p", fn);
        kfree(fn);
        scst_resume_activity();
        cdrom_fileio_close(name);
@@ -3161,9 +3129,7 @@ static void __exit exit_scst_fileio(struct scst_dev_type *devtype,
 
                PRINT_INFO_PR("Virtual device %s unregistered", virt_dev->name);
                TRACE_DBG("virt_id %d", virt_dev->virt_id);
-               TRACE_MEM("kfree for file_name: %p", virt_dev->file_name);
                kfree(virt_dev->file_name);
-               TRACE_MEM("kfree for virt_dev: %p", virt_dev);
                kfree(virt_dev);
        }
        up(&scst_fileio_mutex);