linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, dhowells@redhat.com
Subject: [PATCH 75/76] Ext2: Unionmount devel
Date: Fri, 17 Jun 2011 17:23:43 +0100	[thread overview]
Message-ID: <32541.1308327823@redhat.com> (raw)
In-Reply-To: <20110617160008.30314.22757.stgit@warthog.procyon.org.uk>

From: Valerie Aurora <vaurora@redhat.com>

XXX - works but needs whiteout find entry removed
---

 fs/ext2/dir.c |   62 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 19 deletions(-)


diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index be6e397..4b9cca8 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -535,6 +535,17 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
 	mark_inode_dirty(dir);
 }
 
+/*
+ * Called from three settings:
+ *
+ * - Creating a regular entry - de/page NULL, doesn't exist
+ * - Creating a fallthru - de/page NULL, doesn't exist
+ * - Creating a whiteout - de/page set if it exists
+ *
+ * @new_file_type is either EXT2_FT_WHT, EXT2_FT_FALLTHRU, or 0.  If
+ * 0, file type is determined by inode->i_mode.
+ */
+
 int ext2_add_entry (struct dentry *dentry, struct inode *inode,
 		    ext2_dirent *de, struct page *page,
 		    int new_file_type)
@@ -551,6 +562,13 @@ int ext2_add_entry (struct dentry *dentry, struct inode *inode,
 	loff_t pos;
 	int err;
 
+	if (de) {
+		name_len = EXT2_DIR_REC_LEN(de->name_len);
+		rec_len = ext2_rec_len_from_disk(de->rec_len);
+		printk("%s: given de\n", dentry->d_name.name);
+		goto got_it;
+	}
+
 	/*
 	 * We take care of directory expansion in the same loop.
 	 * This code plays outside i_size, so it locks the page
@@ -576,6 +594,7 @@ int ext2_add_entry (struct dentry *dentry, struct inode *inode,
 				de->rec_len = ext2_rec_len_to_disk(chunk_size);
 				de->inode = 0;
 				de->file_type = 0;
+				printk("%s: allocated new de\n", dentry->d_name.name);
 				goto got_it;
 			}
 			if (de->rec_len == 0) {
@@ -584,15 +603,24 @@ int ext2_add_entry (struct dentry *dentry, struct inode *inode,
 				err = -EIO;
 				goto out_unlock;
 			}
-			err = -EEXIST;
-			if (ext2_match (namelen, name, de))
-				goto out_unlock;
 			name_len = EXT2_DIR_REC_LEN(de->name_len);
 			rec_len = ext2_rec_len_from_disk(de->rec_len);
-			if (!ext2_dirent_in_use(de) && rec_len >= reclen)
+			if (ext2_match(namelen, name, de)) {
+				err = -EEXIST;
+				/* XXX handle whiteouts here too */
+				if (de->file_type != EXT2_FT_FALLTHRU)
+					goto out_unlock;
+				printk("%s: found existing de\n", dentry->d_name.name);
+				goto got_it;
+			}
+			if (!ext2_dirent_in_use(de) && rec_len >= reclen) {
+				printk("%s: reusing empty de\n", dentry->d_name.name);
 				goto got_it;
-			if (rec_len >= name_len + reclen)
+			}
+			if (rec_len >= name_len + reclen) {
+				printk("%s: carving off end of in-use de\n", dentry->d_name.name);
 				goto got_it;
+			}
 			de = (ext2_dirent *) ((char *) de + rec_len);
 		}
 		unlock_page(page);
@@ -603,22 +631,18 @@ int ext2_add_entry (struct dentry *dentry, struct inode *inode,
 
 got_it:
 	/*
-	 * Pre-existing entries with the same name are allowable
-	 * depending on the type of the entry being created.  Regular
-	 * entries replace whiteouts and fallthrus.  Whiteouts replace
-	 * regular entries.  Fallthrus replace nothing.
+	 * Sanity check what we got.  Not allowed:
+	 *  - fallthru replaced by fallthru
+	 *  - whiteout replaced by whiteout or fallthru
+	 *  - not-fallthru replaced by fallthru
 	 */
-	err = -EEXIST;
 	if (ext2_match(namelen, name, de)) {
-		if (new_file_type == EXT2_FT_WHT) {
-			if (de->file_type == EXT2_FT_WHT)
-				goto out_unlock;
-		} else if (new_file_type == EXT2_FT_FALLTHRU) {
-			goto out_unlock;
-		} else if ((de->file_type != EXT2_FT_WHT) &&
-			   (de->file_type != EXT2_FT_FALLTHRU)) {
-			goto out_unlock;
-		}
+		BUG_ON((de->file_type == EXT2_FT_FALLTHRU) &&
+		       (new_file_type == EXT2_FT_FALLTHRU));
+		BUG_ON((de->file_type == EXT2_FT_WHT) &&
+		       (new_file_type == EXT2_FT_FALLTHRU));
+		BUG_ON((de->file_type == EXT2_FT_WHT) &&
+		       (new_file_type = EXT2_FT_WHT));
 	}
 	pos = page_offset(page) +
 		(char*)de - (char*)page_address(page);

  parent reply	other threads:[~2011-06-17 16:23 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 16:00 [RFC][PATCH 00/76] Union Mount David Howells
2011-06-17 16:00 ` [PATCH 01/76] VFS: Make clone_mnt()/copy_tree()/collect_mounts() return errors David Howells
2011-06-17 16:00 ` [PATCH 02/76] VFS: Add hard read-only users count to superblock David Howells
2011-06-17 16:00 ` [PATCH 03/76] VFS: Add CL_NO_SHARED flag to clone_mnt()/copy_tree() David Howells
2011-06-17 16:00 ` [PATCH 04/76] VFS: Add CL_NO_SLAVE " David Howells
2011-06-17 16:00 ` [PATCH 05/76] VFS: Add CL_MAKE_HARD_READONLY " David Howells
2011-06-17 16:01 ` [PATCH 06/76] VFS: Comment follow_mount() and friends David Howells
2011-06-17 16:53   ` Christoph Hellwig
2011-06-17 16:01 ` [PATCH 07/76] VFS: Make lookup_hash() return a struct path David Howells
2011-06-17 16:01 ` [PATCH 08/76] whiteout/NFSD: Don't return information about whiteouts to userspace David Howells
2011-06-17 16:01 ` [PATCH 09/76] whiteout: Define flags and operations for opaque inodes David Howells
2011-06-17 16:01 ` [PATCH 10/76] whiteout: Add vfs_whiteout() and whiteout inode operation David Howells
2011-06-17 16:01 ` [PATCH 11/76] whiteout: Allow removal of a directory with whiteouts David Howells
2011-06-17 16:01 ` [PATCH 12/76] tmpfs: Add whiteout support David Howells
2011-06-17 16:02 ` [PATCH 13/76] ext2: Add ext2_dirent_in_use() David Howells
2011-06-17 16:02 ` [PATCH 14/76] ext2: Split ext2_add_entry() from ext2_add_link() David Howells
2011-06-17 16:02 ` [PATCH 15/76] ext2: Add whiteout support David Howells
2011-06-17 16:02 ` [PATCH 16/76] jffs2: " David Howells
2011-06-17 16:02 ` [PATCH 17/76] VFS: Basic fallthru definitions David Howells
2011-06-17 16:02 ` [PATCH 18/76] ext2: Add fallthru support David Howells
2011-06-17 16:03 ` [PATCH 19/76] tmpfs: " David Howells
2011-06-17 16:03 ` [PATCH 20/76] jffs2: " David Howells
2011-06-17 16:03 ` [PATCH 21/76] union-mount: Union mounts documentation David Howells
2011-06-17 16:03 ` [PATCH 22/76] union-mount: Introduce MNT_UNION and MS_UNION flags David Howells
2011-06-17 16:03 ` [PATCH 23/76] union-mount: Add CONFIG_UNION_MOUNT option David Howells
2011-06-17 16:03 ` [PATCH 24/76] union-mount: Create union_stack structure David Howells
2011-06-17 16:03 ` [PATCH 25/76] union-mount: Add two superblock fields for union mounts David Howells
2011-06-17 16:04 ` [PATCH 26/76] union-mount: Add union_alloc() David Howells
2011-06-17 16:04 ` [PATCH 27/76] union-mount: Add union_find_dir() David Howells
2011-06-17 16:04 ` [PATCH 28/76] union-mount: Create d_free_unions() David Howells
2011-06-17 16:04 ` [PATCH 29/76] union-mount: Free union stack on removal of topmost dentry from dcache David Howells
2011-06-17 16:04 ` [PATCH 30/76] union-mount: Create union_add_dir() David Howells
2011-06-17 16:04 ` [PATCH 31/76] union-mount: Add union_create_topmost_dir() David Howells
2011-06-17 16:04 ` [PATCH 32/76] union-mount: Create IS_MNT_UNION() David Howells
2011-06-17 16:05 ` [PATCH 33/76] union-mount: Create needs_lookup_union() David Howells
2011-06-17 16:05 ` [PATCH 34/76] union-mount: Create check_topmost_union_mnt() David Howells
2011-06-17 16:05 ` [PATCH 35/76] union-mount: Add clone_union_tree() and put_union_sb() David Howells
2011-06-17 16:05 ` [PATCH 36/76] union-mount: Create build_root_union() David Howells
2011-06-17 16:05 ` [PATCH 37/76] union-mount: Create prepare_mnt_union() and cleanup_mnt_union() David Howells
2011-06-17 16:05 ` [PATCH 38/76] union-mount: Prevent improper union-related remounts David Howells
2011-06-17 16:05 ` [PATCH 39/76] union-mount: Prevent topmost file system from being mounted elsewhere David Howells
2011-06-17 16:06 ` [PATCH 40/76] union-mount: Prevent bind mounts of union mounts David Howells
2011-06-17 16:06 ` [PATCH 41/76] union-mount: Implement union mount David Howells
2011-06-17 16:06 ` [PATCH 42/76] union-mount: Temporarily disable some syscalls David Howells
2011-06-17 16:06 ` [PATCH 43/76] union-mount: Basic infrastructure of __lookup_union() David Howells
2011-06-17 16:06 ` [PATCH 44/76] union-mount: Process negative dentries in __lookup_union() David Howells
2011-06-17 16:06 ` [PATCH 45/76] union-mount: Return files found in lower layers " David Howells
2011-06-17 16:06 ` [PATCH 46/76] union-mount: Build union stack " David Howells
2011-06-17 16:07 ` [PATCH 47/76] union-mount: Follow mount " David Howells
2011-06-17 16:07 ` [PATCH 48/76] union-mount: Add lookup_union() David Howells
2011-06-17 16:07 ` [PATCH 49/76] union-mount: Add do_lookup_union() wrapper for __lookup_union() David Howells
2011-06-17 16:07 ` [PATCH 50/76] union-mount: Call union lookup functions in lookup path David Howells
2011-06-17 16:07 ` [PATCH 51/76] union-mount: Create whiteout on unlink() David Howells
2011-06-17 16:07 ` [PATCH 52/76] union-mount: Create whiteout on rmdir() David Howells
2011-06-17 16:07 ` [PATCH 53/76] union-mount: Set opaque flag on new directories in unioned file systems David Howells
2011-06-17 16:08 ` [PATCH 54/76] union-mount: Copy up directory entries on first readdir() David Howells
2011-06-17 16:08 ` [PATCH 55/76] union-mount: Add generic_readdir_fallthru() helper David Howells
2011-06-17 16:08 ` [PATCH 56/76] fallthru: ext2 support for lookup of d_type/d_ino in fallthrus David Howells
2011-06-17 16:08 ` [PATCH 57/76] fallthru: tmpfs " David Howells
2011-06-17 16:08 ` [PATCH 58/76] fallthru: jffs2 " David Howells
2011-06-17 16:08 ` [PATCH 59/76] VFS: Split inode_permission() and create path_permission() David Howells
2011-06-17 16:09 ` [PATCH 60/76] VFS: Create user_path_nd() to lookup both parent and target David Howells
2011-06-17 16:09 ` [PATCH 61/76] union-mount: In-kernel file copyup routines David Howells
2011-06-17 16:09 ` [PATCH 62/76] union-mount: Implement union-aware access()/faccessat() David Howells
2011-06-17 16:09 ` [PATCH 63/76] union-mount: Implement union-aware link() David Howells
2011-06-17 16:09 ` [PATCH 64/76] union-mount: Implement union-aware rename() David Howells
2011-06-17 16:09 ` [PATCH 65/76] union-mount: Implement union-aware writable open() David Howells
2011-06-17 16:09 ` [PATCH 66/76] union-mount: Implement union-aware chown() David Howells
2011-06-17 16:10 ` [PATCH 67/76] union-mount: Implement union-aware truncate() David Howells
2011-06-17 16:10 ` [PATCH 68/76] union-mount: Implement union-aware chmod()/fchmodat() David Howells
2011-06-17 16:10 ` [PATCH 69/76] union-mount: Implement union-aware lchown() David Howells
2011-06-17 16:10 ` [PATCH 70/76] union-mount: Implement union-aware utimensat() David Howells
2011-06-17 16:10 ` [PATCH 71/76] union-mount: Implement union-aware setxattr() David Howells
2011-06-17 16:10 ` [PATCH 72/76] union-mount: Implement union-aware lsetxattr() David Howells
2011-06-17 16:10 ` [PATCH 73/76] union-mount: Pass mount flags to sget() David Howells
2011-06-17 16:11 ` [PATCH 74/76] union-mount: Duplicate the i_{, dir_}mutex lock classes and use for upper layer David Howells
2011-06-17 16:11 ` [PATCH 76/76] Temporary commit David Howells
2011-06-17 16:23 ` David Howells [this message]
2011-06-17 16:44 ` [RFC][PATCH 00/76] Union Mount Sedat Dilek

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=32541.1308327823@redhat.com \
    --to=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).