2002-08-07 01:01:34

by Anton Altaparmakov

[permalink] [raw]
Subject: [BK-PATCH-2.5] NTFS 2.0.24: Cleanups

Linus, please do a

bk pull http://linux-ntfs.bkbits.net/ntfs-tng-2.5

Thanks! This is just some cleanups, mostly the BUG_ON() cleanups from
Adam J. Richter. Just to relax a bit after the big changes in the
last ntfs update. (-;

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS maintainer / IRC: #ntfs on irc.openprojects.net
WWW: http://linux-ntfs.sf.net/, http://www-stu.christs.cam.ac.uk/~aia21/

===================================================================

This will update the following files:

Documentation/filesystems/ntfs.txt | 3 +++
fs/ntfs/ChangeLog | 16 ++++++++++++++++
fs/ntfs/Makefile | 2 +-
fs/ntfs/attrib.c | 15 ++++++++++-----
fs/ntfs/compress.c | 3 ++-
fs/ntfs/file.c | 9 ++++++++-
fs/ntfs/inode.c | 8 ++++++--
fs/ntfs/super.c | 21 +++++++++++++++++----
fs/ntfs/volume.h | 2 ++
9 files changed, 65 insertions(+), 14 deletions(-)

through these ChangeSets:

<[email protected]> (02/08/07 1.471)
NTFS: 2.0.24 - Cleanups.
- Treat BUG_ON() as ASSERT() not VERIFY(), i.e. do not use side effects
inside BUG_ON(). (Adam J. Richter)
- Split logical OR expressions inside BUG_ON() into individual BUG_ON()
calls for improved debugging. (Adam J. Richter)
- Add errors flag to the ntfs volume state, accessed via
NVol{,Set,Clear}Errors(vol).
- Do not allow read-write remounts of read-only volumes with errors.
- Clarify comment for ntfs file operation sendfile which was added by
Christoph Hellwig a while ago (just using generic_file_sendfile())
to say that ntfs ->sendfile is only used for the case where the
source data is on the ntfs partition and the destination is
somewhere else, i.e. nothing we need to concern ourselves with.


diff -Nru a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
--- a/Documentation/filesystems/ntfs.txt Wed Aug 7 01:48:11 2002
+++ b/Documentation/filesystems/ntfs.txt Wed Aug 7 01:48:11 2002
@@ -247,6 +247,9 @@

Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.

+2.0.24:
+ - Small internal cleanups.
+ - Support for sendfile system call. (Christoph Hellwig)
2.0.23:
- Massive internal locking changes to mft record locking. Fixes
various race conditions and deadlocks.
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/ChangeLog Wed Aug 7 01:48:11 2002
@@ -2,6 +2,22 @@
- Find and fix bugs.
- Enable NFS exporting of NTFS.

+2.0.24 - Cleanups.
+
+ - Treat BUG_ON() as ASSERT() not VERIFY(), i.e. do not use side effects
+ inside BUG_ON(). (Adam J. Richter)
+ - Split logical OR expressions inside BUG_ON() into individual BUG_ON()
+ calls for improved debugging. (Adam J. Richter)
+ - Add errors flag to the ntfs volume state, accessed via
+ NVol{,Set,Clear}Errors(vol).
+ - Do not allow read-write remounts of read-only volumes with errors.
+ - Clarify comment for ntfs file operation sendfile which was added by
+ Christoph Hellwig a while ago (just using generic_file_sendfile())
+ to say that ntfs ->sendfile is only used for the case where the
+ source data is on the ntfs partition and the destination is
+ somewhere else, i.e. nothing we need to concern ourselves with.
+ - Add generic_file_write() as our ntfs file write operation.
+
2.0.23 - Major bug fixes (races, deadlocks, non-i386 architectures).

- Massive internal locking changes to mft record locking. Fixes lock
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/Makefile Wed Aug 7 01:48:11 2002
@@ -5,7 +5,7 @@
ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o

-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.23\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.24\"

ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
--- a/fs/ntfs/attrib.c Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/attrib.c Wed Aug 7 01:48:11 2002
@@ -110,7 +110,8 @@
static inline BOOL ntfs_are_rl_mergeable(run_list_element *dst,
run_list_element *src)
{
- BUG_ON(!dst || !src);
+ BUG_ON(!dst);
+ BUG_ON(!src);

if ((dst->lcn < 0) || (src->lcn < 0)) /* Are we merging holes? */
return FALSE;
@@ -192,7 +193,8 @@
BOOL right;
int magic;

- BUG_ON(!dst || !src);
+ BUG_ON(!dst);
+ BUG_ON(!src);

/* First, check if the right hand end needs merging. */
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
@@ -258,7 +260,8 @@
BOOL hole = FALSE; /* Following a hole */
int magic;

- BUG_ON(!dst || !src);
+ BUG_ON(!dst);
+ BUG_ON(!src);

/* disc => Discontinuity between the end of @dst and the start of @src.
* This means we might need to insert a hole.
@@ -362,7 +365,8 @@
BOOL right;
int magic;

- BUG_ON(!dst || !src);
+ BUG_ON(!dst);
+ BUG_ON(!src);

/* First, merge the left and right ends, if necessary. */
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
@@ -423,7 +427,8 @@
static inline run_list_element *ntfs_rl_split(run_list_element *dst, int dsize,
run_list_element *src, int ssize, int loc)
{
- BUG_ON(!dst || !src);
+ BUG_ON(!dst);
+ BUG_ON(!src);

/* Space required: @dst size + @src size + one new hole. */
dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1);
diff -Nru a/fs/ntfs/compress.c b/fs/ntfs/compress.c
--- a/fs/ntfs/compress.c Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/compress.c Wed Aug 7 01:48:11 2002
@@ -467,7 +467,8 @@
* Bad things happen if we get here for anything that is not an
* unnamed $DATA attribute.
*/
- BUG_ON(ni->type != AT_DATA || ni->name_len);
+ BUG_ON(ni->type != AT_DATA);
+ BUG_ON(ni->name_len);

pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS);

diff -Nru a/fs/ntfs/file.c b/fs/ntfs/file.c
--- a/fs/ntfs/file.c Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/file.c Wed Aug 7 01:48:11 2002
@@ -51,8 +51,15 @@
struct file_operations ntfs_file_ops = {
.llseek = generic_file_llseek, /* Seek inside file. */
.read = generic_file_read, /* Read from file. */
+#ifdef NTFS_RW
+ .write = generic_file_write, /* Write to a file. */
+#endif
.mmap = generic_file_mmap, /* Mmap file. */
- .sendfile = generic_file_sendfile,/* Zero-copy data send. */
+ .sendfile = generic_file_sendfile,/* Zero-copy data send with the
+ data source being on the
+ ntfs partition. We don't
+ need to care about the data
+ destination. */
.open = ntfs_file_open, /* Open file. */
};

diff -Nru a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/inode.c Wed Aug 7 01:48:11 2002
@@ -278,7 +278,9 @@
ntfs_inode *ni = NTFS_I(inode);

ntfs_debug("Entering.");
- BUG_ON(ni->page || !atomic_dec_and_test(&ni->count));
+ BUG_ON(ni->page);
+ if (!atomic_dec_and_test(&ni->count))
+ BUG();
kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode));
}

@@ -299,7 +301,9 @@
void ntfs_destroy_extent_inode(ntfs_inode *ni)
{
ntfs_debug("Entering.");
- BUG_ON(ni->page || !atomic_dec_and_test(&ni->count));
+ BUG_ON(ni->page);
+ if (!atomic_dec_and_test(&ni->count))
+ BUG();
kmem_cache_free(ntfs_inode_cache, ni);
}

diff -Nru a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/super.c Wed Aug 7 01:48:11 2002
@@ -307,6 +307,23 @@

ntfs_debug("Entering with remount options string: %s", opt);

+#ifndef NTFS_RW
+ /* For read-only compiled driver, enforce all read-only flags. */
+ *flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME;
+#else
+ /*
+ * For the read-write compiled driver, if we are remounting read-write,
+ * make sure there aren't any volume errors.
+ */
+ if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
+ if (NVolErrors(vol)) {
+ ntfs_error(sb, "Volume has errors and is read-only."
+ "Cannot remount read-write.");
+ return -EROFS;
+ }
+ }
+#endif
+
// FIXME/TODO: If left like this we will have problems with rw->ro and
// ro->rw, as well as with sync->async and vice versa remounts.
// Note: The VFS already checks that there are no pending deletes and
@@ -323,10 +340,6 @@

if (!parse_options(vol, opt))
return -EINVAL;
-
-#ifndef NTFS_RW
- *flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME;
-#endif

return 0;
}
diff -Nru a/fs/ntfs/volume.h b/fs/ntfs/volume.h
--- a/fs/ntfs/volume.h Wed Aug 7 01:48:11 2002
+++ b/fs/ntfs/volume.h Wed Aug 7 01:48:11 2002
@@ -101,6 +101,7 @@
* Defined bits for the flags field in the ntfs_volume structure.
*/
typedef enum {
+ NV_Errors, /* 1: Volume has errors, prevent remount rw. */
NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
NV_CaseSensitive, /* 1: Treat file names as case sensitive and
create filenames in the POSIX namespace.
@@ -127,6 +128,7 @@
}

/* Emit the ntfs volume bitops functions. */
+NVOL_FNS(Errors)
NVOL_FNS(ShowSystemFiles)
NVOL_FNS(CaseSensitive)


===================================================================

This BitKeeper patch contains the following changesets:
+
## Wrapped with gzip_uu ##


begin 664 bkpatch26415
M'XL(`$MN4#T``^5:;6_;.!+^+/V*:0KTG*ZMB'J7%RDVS4LWUS8IG+1[>RA@
MT!)EZ]:6#(E.-ECM?[\A:<>V'#6UF^`^7!)8ED3-D#//S#P<Y25\+EG1U6A*
M+:*_A%_SDG>UB&:<#HR,<;S4RW.\=#`KBX.RB`YX-M3QZB?*HQ'<L*+L:L2P
M[Z_PNRGK:KW3=Y\_'/5T_?`0CD<T&[(KQN'P4.=Y<4/'<?D+Y:-QGAF\H%DY
M89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U8`!99Q=2+EKX^;K99K$+)%]['[O-UTS)`W1M,,'6$M;.W@-OTF:@@BGDK88
M\/I`?XG+3!/]Q)59"3]=%+3@:G51B^MM%/9O5N2=*)_>*8HF;BE.*OF;_`&8
MWU-4;L`$]U)$;CEBG=$9\!NRN3S[!U\9L:!J%-D<'>0SKC@?BEY1M&2`<EVK
M^)[W76H`WZJITXSP6E/GOIQ[H:G*>>AND09QTV@]"\3_KUYI((60/;6&N)N[
M;)?$:P6JTN/!7DNM(E6(;)LFT'I!>3[!F(E9U,<=2I\C-ENOQ*A(;.C$%DD\
MVI)TP+0D'<##DPA<Q?V\NUS#_5:MZV;<UUK7"]Q;!/<>*K5;YC;;#A\ZSK,@
M_PFVU^)%B>C(-^!I;HI=$CG:'H@O4GFVELLQP9XAW)?S$GP!,R\"OTAQ"]4&
MEF$\8%857;?E,-&:*&4"U%[+[U`=PD>4>7)Y\>%WJ,3WB\NCZ_./IXN3D_.>
M//\9:P%NE85NW$`K_2+/KIAL8Q((3MQ+B[P\MZ;(\,L'VE+0!+=R4,[4UKZ0
MPS&_X]Y]8>UE&T-.7""^50XZ;\J^6L*KY0KVX=4K>-%ZO7EC'_["*!#/BG[+
M2H]%W="$I_I2$<INP]X7I7J$>7#>UA'-A+1<&M/84^5E[YAF`D'S):ZLS]@3
M$:II!>.S(H/.:>_R[$I<^5O'OWEI_8I!C@3>60O-Q6N86FQN]Y:G.3C7W_+X
M9H"QXML.5B7?W8%X6<_5RMSYO?,W>VKO0;W-:@C7A7%VB5=T"*9K[>)+7VEL
M:R)421<VX-0&+'8W+%O!S:T,S'-B8<SK%U\N/_3/+JY:2M#^\E\ZHA&+_BAG
2DT//&\3$)H[^7PB?+$`D(@``
`
end


2002-08-07 01:29:10

by Erik Andersen

[permalink] [raw]
Subject: Re: [BK-PATCH-2.5] NTFS 2.0.24: Cleanups

On Wed Aug 07, 2002 at 02:05:04AM +0100, Anton Altaparmakov wrote:
> - Do not allow read-write remounts of read-only volumes with errors.

I thought the current NTFS driver does not yet support writing...

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

2002-08-07 08:48:22

by Anton Altaparmakov

[permalink] [raw]
Subject: Re: [BK-PATCH-2.5] NTFS 2.0.24: Cleanups

At 02:32 07/08/02, Erik Andersen wrote:
>On Wed Aug 07, 2002 at 02:05:04AM +0100, Anton Altaparmakov wrote:
> > - Do not allow read-write remounts of read-only volumes with errors.
>
>I thought the current NTFS driver does not yet support writing...

Correct, and if you look at the code you will notice the #ifdef NTFS_RW
around it... The read-only compiled driver doesn't have any write related
code. Only the read-write compiled driver has, but at the moment this is
just adding necesary safety bits before starting to add actual write code.
Writing is under development and you will be seing more and more bits
related to it appearing. (-:

Best regards,

Anton


--
"I've not lost my mind. It's backed up on tape somewhere." - Unknown
--
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS Maintainer / IRC: #ntfs on irc.openprojects.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

2002-08-07 09:36:08

by Erik Andersen

[permalink] [raw]
Subject: Re: [BK-PATCH-2.5] NTFS 2.0.24: Cleanups

On Wed Aug 07, 2002 at 09:52:26AM +0100, Anton Altaparmakov wrote:
> At 02:32 07/08/02, Erik Andersen wrote:
> >On Wed Aug 07, 2002 at 02:05:04AM +0100, Anton Altaparmakov wrote:
> >> - Do not allow read-write remounts of read-only volumes with errors.
> >
> >I thought the current NTFS driver does not yet support writing...
>
> Correct, and if you look at the code you will notice the #ifdef NTFS_RW
> around it... The read-only compiled driver doesn't have any write related
> code. Only the read-write compiled driver has, but at the moment this is
> just adding necesary safety bits before starting to add actual write code.
> Writing is under development and you will be seing more and more bits
> related to it appearing. (-:

Very cool. I'm looking forward to trying it. I occasionally
need to interoperate with win2k (ick), so I'm grateful for your
efforts!

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

2002-08-08 13:12:19

by Denis Vlasenko

[permalink] [raw]
Subject: Re: [BK-PATCH-2.5] NTFS 2.0.24: Cleanups

On 7 August 2002 07:39, Erik Andersen wrote:
> > Correct, and if you look at the code you will notice the #ifdef NTFS_RW
> > around it... The read-only compiled driver doesn't have any write related
> > code. Only the read-write compiled driver has, but at the moment this is
> > just adding necesary safety bits before starting to add actual write
> > code. Writing is under development and you will be seing more and more
> > bits related to it appearing. (-:
>
> Very cool. I'm looking forward to trying it. I occasionally
> need to interoperate with win2k (ick), so I'm grateful for your
> efforts!

Me too. Although I have too many part-time jobs, I am willing to test it
and even help to code if my little brain can cope with.
--
vda