linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu, darrick.wong@oracle.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 14/21] e2fsck: clear extents and inline_data flags from fifo/socket/device inodes
Date: Mon, 04 Aug 2014 18:06:29 -0700	[thread overview]
Message-ID: <20140805010629.2611.91726.stgit@birch.djwong.org> (raw)
In-Reply-To: <20140805010457.2611.89813.stgit@birch.djwong.org>

Since fifo, socket, and device inodes cannot have inline data or
extents, strip off these flags if we find them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c           |   22 ++++++++++++++++++++++
 e2fsck/problem.c         |    6 ++++++
 e2fsck/problem.h         |    3 +++
 tests/f_extents/expect.1 |    3 +++
 4 files changed, 34 insertions(+)


diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 8bd08ee..d41b230 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -272,6 +272,24 @@ exit_inline:
 }
 
 /*
+ * If the extents or inlinedata flags are set on the inode, offer to clear 'em.
+ */
+#define BAD_SPECIAL_FLAGS (EXT4_EXTENTS_FL | EXT4_INLINE_DATA_FL)
+static void check_extents_inlinedata(e2fsck_t ctx,
+				     struct problem_context *pctx)
+{
+	if (!(pctx->inode->i_flags & BAD_SPECIAL_FLAGS))
+		return;
+
+	if (!fix_problem(ctx, PR_1_SPECIAL_EXTENTS_IDATA, pctx))
+		return;
+
+	pctx->inode->i_flags &= ~BAD_SPECIAL_FLAGS;
+	e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
+}
+#undef BAD_SPECIAL_FLAGS
+
+/*
  * If the immutable (or append-only) flag is set on the inode, offer
  * to clear it.
  */
@@ -1396,11 +1414,13 @@ void e2fsck_pass1(e2fsck_t ctx)
 			ctx->fs_regular_count++;
 		} else if (LINUX_S_ISCHR (inode->i_mode) &&
 			   e2fsck_pass1_check_device_inode(fs, inode)) {
+			check_extents_inlinedata(ctx, &pctx);
 			check_immutable(ctx, &pctx);
 			check_size(ctx, &pctx);
 			ctx->fs_chardev_count++;
 		} else if (LINUX_S_ISBLK (inode->i_mode) &&
 			   e2fsck_pass1_check_device_inode(fs, inode)) {
+			check_extents_inlinedata(ctx, &pctx);
 			check_immutable(ctx, &pctx);
 			check_size(ctx, &pctx);
 			ctx->fs_blockdev_count++;
@@ -1421,11 +1441,13 @@ void e2fsck_pass1(e2fsck_t ctx)
 		}
 		else if (LINUX_S_ISFIFO (inode->i_mode) &&
 			 e2fsck_pass1_check_device_inode(fs, inode)) {
+			check_extents_inlinedata(ctx, &pctx);
 			check_immutable(ctx, &pctx);
 			check_size(ctx, &pctx);
 			ctx->fs_fifo_count++;
 		} else if ((LINUX_S_ISSOCK (inode->i_mode)) &&
 			   e2fsck_pass1_check_device_inode(fs, inode)) {
+			check_extents_inlinedata(ctx, &pctx);
 			check_immutable(ctx, &pctx);
 			check_size(ctx, &pctx);
 			ctx->fs_sockets_count++;
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 9081277..26ee51b 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1050,6 +1050,12 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@i %i has INLINE_DATA_FL flag but @a not found.  "),
 	  PROMPT_TRUNCATE, 0 },
 
+	/* Extents/inlinedata flag set on a device or socket inode */
+	{ PR_1_SPECIAL_EXTENTS_IDATA,
+	  N_("Special (@v/socket/fifo) file (@i %i) has extents\n"
+	     "or inline-data flag set.  "),
+	  PROMPT_CLEAR, PR_PREEN_OK | PR_PREEN_NO | PR_NO_OK },
+
 	/* Pass 1b errors */
 
 	/* Pass 1B: Rescan for duplicate/bad blocks */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 1f0be2d..3c5e11a 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -612,6 +612,9 @@ struct problem_context {
 /* Inode has INLINE_DATA_FL flag but extended attribute not found */
 #define PR_1_INLINE_DATA_NO_ATTR	0x010075
 
+/* extents/inlinedata set on fifo/socket/device */
+#define PR_1_SPECIAL_EXTENTS_IDATA	0x010076
+
 /*
  * Pass 1b errors
  */
diff --git a/tests/f_extents/expect.1 b/tests/f_extents/expect.1
index 2abe32e..953162c 100644
--- a/tests/f_extents/expect.1
+++ b/tests/f_extents/expect.1
@@ -22,6 +22,9 @@ Clear inode? yes
 
 Inode 18, i_blocks is 2, should be 0.  Fix? yes
 
+Special (device/socket/fifo) file (inode 19) has extents
+or inline-data flag set.  Clear? yes
+
 Pass 2: Checking directory structure
 Entry 'fbad-flag' in / (2) has deleted/unused inode 18.  Clear? yes
 


  parent reply	other threads:[~2014-08-05  1:06 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05  1:04 [PATCH 00/21] e2fsprogs Summer 2014 patchbomb, part 3 Darrick J. Wong
2014-08-05  1:05 ` [PATCH 01/21] e2fuzz: fix build problems on macosx and i386 linux Darrick J. Wong
2014-08-10 22:16   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 02/21] e2fsck: convert 'delete files' warning to a proper fix_problem error Darrick J. Wong
2014-08-10 22:16   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 03/21] libext2fs: check EA value offset Darrick J. Wong
2014-08-10 22:21   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 04/21] libext2fs/e2fsck: don't run off the end of the EA block Darrick J. Wong
2014-08-10 22:22   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 05/21] misc: fix various endianness problems with inline_data Darrick J. Wong
2014-08-10 22:23   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 06/21] libext2fs: strict inline data overwrite should not return ENOSPC Darrick J. Wong
2014-08-10 22:27   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 07/21] libext2fs: remove EA when inline data is less than 60 bytes Darrick J. Wong
2014-08-08 22:46   ` [PATCH v2 07/21] libext2fs: don't fail inline data operations if there's no EA Darrick J. Wong
2014-08-10 22:31     ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 08/21] libext2fs: fix memory leak when failing to iterate inline_data directory Darrick J. Wong
2014-08-10 22:32   ` Theodore Ts'o
2014-08-05  1:05 ` [PATCH 09/21] e2fsck: check ea-in-inode regions for overlap Darrick J. Wong
2014-08-08 22:43   ` [PATCH v2 " Darrick J. Wong
2014-08-10 22:35     ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 10/21] e2fsck: clear inline_data inode flag if EA missing Darrick J. Wong
2014-08-08 22:44   ` [PATCH v2 " Darrick J. Wong
2014-08-10 22:37     ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 11/21] e2fsck: handle inline data symlinks Darrick J. Wong
2014-08-10 22:38   ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 12/21] e2fsck: check inline directory data "block" first Darrick J. Wong
2014-08-10 22:40   ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 13/21] e2fsck: don't try to iterate blocks of an inline_data inode when deallocating it Darrick J. Wong
2014-08-10 22:40   ` Theodore Ts'o
2014-08-05  1:06 ` Darrick J. Wong [this message]
2014-08-10 22:41   ` [PATCH 14/21] e2fsck: clear extents and inline_data flags from fifo/socket/device inodes Theodore Ts'o
2014-08-05  1:06 ` [PATCH 15/21] e2fsck: fix conflicting extents|inlinedata inode flags Darrick J. Wong
2014-08-08 16:24   ` [PATCH v2 " Darrick J. Wong
2014-08-10 22:43     ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 16/21] e2fsck: do a better job of fixing i_size of inline directories Darrick J. Wong
2014-08-10 22:44   ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 17/21] e2fsck: use the correct block size when salvaging directories Darrick J. Wong
2014-08-10 22:45   ` Theodore Ts'o
2014-08-05  1:06 ` [PATCH 18/21] e2fsck: check inline dir size is a multiple of 4 Darrick J. Wong
2014-08-10 22:47   ` Theodore Ts'o
2014-08-05  1:07 ` [PATCH 19/21] e2fsck: be more careful in assuming inline_data inodes are directories Darrick J. Wong
2014-08-08 16:22   ` [PATCH v2 " Darrick J. Wong
2014-08-10 22:49     ` Theodore Ts'o
2014-08-05  1:07 ` [PATCH 20/21] e2fsck: don't set prev after processing '..' on an inline dir Darrick J. Wong
2014-08-10 22:50   ` Theodore Ts'o
2014-08-05  1:07 ` [PATCH 21/21] tests: add regression tests for inlinedata fixes Darrick J. Wong
2014-08-08 22:47   ` [PATCH v2 " Darrick J. Wong

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=20140805010629.2611.91726.stgit@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).