NTFS: Fix compilation when configured read-only.

- Add ifdef NTFS_RW around write specific code if fs/ntfs/runlist.[hc] and
  fs/ntfs/attrib.[hc].
- Minor bugfix to fs/ntfs/attrib.c::ntfs_attr_make_non_resident() where the
  runlist was not freed in all error cases.
- Add fs/ntfs/runlist.[hc]::ntfs_rl_find_vcn_nolock().

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 97e6fb0..1b95f392 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1057,6 +1057,8 @@
 	return;
 }
 
+#ifdef NTFS_RW
+
 /**
  * ntfs_attr_find_in_attrdef - find an attribute in the $AttrDef system file
  * @vol:	ntfs volume to which the attribute belongs
@@ -1243,6 +1245,13 @@
  *	-ENOSPC	- Not enough disk space.
  *	-EINVAL	- Attribute not defined on the volume.
  *	-EIO	- I/o error or other error.
+ * Note that -ENOSPC is also returned in the case that there is not enough
+ * space in the mft record to do the conversion.  This can happen when the mft
+ * record is already very full.  The caller is responsible for trying to make
+ * space in the mft record and trying again.  FIXME: Do we need a separate
+ * error return code for this kind of -ENOSPC or is it always worth trying
+ * again in case the attribute may then fit in a resident state so no need to
+ * make it non-resident at all?  Ho-hum...  (AIA)
  *
  * NOTE to self: No changes in the attribute list are required to move from
  *		 a resident to a non-resident attribute.
@@ -1520,13 +1529,13 @@
 rl_err_out:
 	if (rl) {
 		if (ntfs_cluster_free_from_rl(vol, rl) < 0) {
-			ntfs_free(rl);
 			ntfs_error(vol->sb, "Failed to release allocated "
 					"cluster(s) in error code path.  Run "
 					"chkdsk to recover the lost "
 					"cluster(s).");
 			NVolSetErrors(vol);
 		}
+		ntfs_free(rl);
 page_err_out:
 		unlock_page(page);
 		page_cache_release(page);
@@ -1680,3 +1689,5 @@
 	ntfs_debug("Done.");
 	return 0;
 }
+
+#endif /* NTFS_RW */