public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <bgerst@didntduck.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] struct super_block cleanup - shmfs
Date: Wed, 13 Mar 2002 19:46:45 -0500	[thread overview]
Message-ID: <3C8FF2F5.4060100@didntduck.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 73 bytes --]

Seperates shmem_sb_info from struct super_block.

-- 

						Brian Gerst

[-- Attachment #2: sb-shmem-1 --]
[-- Type: text/plain, Size: 3418 bytes --]

diff -urN linux-2.5.7-pre1/include/linux/fs.h linux/include/linux/fs.h
--- linux-2.5.7-pre1/include/linux/fs.h	Tue Mar 12 22:44:13 2002
+++ linux/include/linux/fs.h	Wed Mar 13 19:33:09 2002
@@ -474,7 +474,6 @@
 	return &list_entry(socket, struct socket_alloc, socket)->vfs_inode;
 }
 
-#include <linux/shmem_fs.h>
 /* will die */
 #include <linux/coda_fs_i.h>
 #include <linux/ext3_fs_i.h>
@@ -715,7 +714,6 @@
 		struct affs_sb_info	affs_sb;
 		struct ufs_sb_info	ufs_sb;
 		struct efs_sb_info	efs_sb;
-		struct shmem_sb_info	shmem_sb;
 		struct romfs_sb_info	romfs_sb;
 		struct smb_sb_info	smbfs_sb;
 		struct hfs_sb_info	hfs_sb;
diff -urN linux-2.5.7-pre1/ipc/shm.c linux/ipc/shm.c
--- linux-2.5.7-pre1/ipc/shm.c	Thu Mar  7 21:18:32 2002
+++ linux/ipc/shm.c	Wed Mar 13 19:20:49 2002
@@ -23,6 +23,7 @@
 #include <linux/file.h>
 #include <linux/mman.h>
 #include <linux/proc_fs.h>
+#include <linux/shmem_fs.h>
 #include <asm/uaccess.h>
 
 #include "util.h"
diff -urN linux-2.5.7-pre1/mm/shmem.c linux/mm/shmem.c
--- linux-2.5.7-pre1/mm/shmem.c	Tue Mar 12 22:44:13 2002
+++ linux/mm/shmem.c	Wed Mar 13 19:15:15 2002
@@ -28,6 +28,7 @@
 #include <linux/locks.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/shmem_fs.h>
 
 #include <asm/uaccess.h>
 
@@ -36,7 +37,10 @@
 
 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
 
-#define SHMEM_SB(sb) (&sb->u.shmem_sb)
+static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
+{
+	return sb->u.generic_sbp;
+}
 
 static struct super_operations shmem_ops;
 static struct address_space_operations shmem_aops;
@@ -1255,7 +1259,7 @@
 
 static int shmem_remount_fs (struct super_block *sb, int *flags, char *data)
 {
-	struct shmem_sb_info *sbinfo = &sb->u.shmem_sb;
+	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 	unsigned long max_blocks = sbinfo->max_blocks;
 	unsigned long max_inodes = sbinfo->max_inodes;
 
@@ -1276,8 +1280,15 @@
 	struct dentry * root;
 	unsigned long blocks, inodes;
 	int mode   = S_IRWXUGO | S_ISVTX;
-	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
+	struct shmem_sb_info *sbinfo;
 	struct sysinfo si;
+	int err;
+
+	sbinfo = kmalloc(sizeof(struct shmem_sb_info), GFP_KERNEL);
+	if (!sbinfo)
+		return -ENOMEM;
+	sb->u.generic_sbp = sbinfo;
+	memset(sbinfo, 0, sizeof(struct shmem_sb_info));
 
 	/*
 	 * Per default we only allow half of the physical ram per
@@ -1289,7 +1300,8 @@
 #ifdef CONFIG_TMPFS
 	if (shmem_parse_options (data, &mode, &blocks, &inodes)) {
 		printk(KERN_ERR "tmpfs invalid option\n");
-		return -EINVAL;
+		err = -EINVAL;
+		goto out_sbinfo;
 	}
 #endif
 
@@ -1304,16 +1316,30 @@
 	sb->s_magic = TMPFS_MAGIC;
 	sb->s_op = &shmem_ops;
 	inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
-	if (!inode)
-		return -ENOMEM;
+	if (!inode) {
+		err = -ENOMEM;
+		goto out_sbinfo;
+	}
 
 	root = d_alloc_root(inode);
 	if (!root) {
-		iput(inode);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto out_iput;
 	}
 	sb->s_root = root;
 	return 0;
+out_iput:
+	iput(inode);
+out_sbinfo:
+	sb->u.generic_sbp = NULL;
+	kfree(sbinfo);
+	return err;
+}
+
+static void shmem_put_super(struct super_block *sb)
+{
+	kfree(sb->u.generic_sbp);
+	sb->u.generic_sbp = NULL;
 }
 
 static kmem_cache_t * shmem_inode_cachep;
@@ -1407,6 +1433,7 @@
 #endif
 	delete_inode:	shmem_delete_inode,
 	put_inode:	force_delete,	
+	put_super:	shmem_put_super,
 };
 
 static struct vm_operations_struct shmem_vm_ops = {

                 reply	other threads:[~2002-03-14  0:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C8FF2F5.4060100@didntduck.org \
    --to=bgerst@didntduck.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox