Skip to contentSkip to conversation

smbfs / loop: problematic or not unuseable?

DISCUSSION Nico Schottelius 2 participants 4 messages Feb 16, 2004 – Feb 17, 2004

lore
Share & tools
lore
#0 lore raw

Hello!

While still suffering from my more or less dead harddisk I am seeing other nice problems. I copied my blowfish encrypted partition to a samba server. Now I want to mount it and use it:

pc-it-nico# mount
[...]
//fs2/home on /home/nico/fs2 type smbfs (rw)

pc-it-nico# mount /home/nico/fs2/home-13-Feb-2004.tar.crypt /tmp/ -o loop,encryption=blowfish Password:
ioctl: LOOP_SET_FD: Invalid argument

Well, let's try to use a local copy:

pc-it-nico# cd ~nico/fs2
pc-it-nico# cp home-13-Feb-2004.tar.crypt ..
pc-it-nico# cd ..
pc-it-nico# mount -t xfs home-13-Feb-2004.tar.crypt scice -o loop,encryption=blowfish pc-it-nico#

This works fine.

Just wanted to report this and ask whether this is what it should be.

Greetings,

Nico

ps: If somebody can recommened me a good manufacturer for 2.5" notebook
disks, please send me a private mail. I am looking for something running longer than 2 months, having some performance, still beiing not too loud :)

#1 lore raw
Quoted 6 lines · Nico Schottelius

Hello!

While still suffering from my more or less dead harddisk I am seeing other nice problems. I copied my blowfish encrypted partition to a samba server. Now I want to mount it and use it:

Quoted 7 lines

pc-it-nico# mount
[...]
//fs2/home on /home/nico/fs2 type smbfs (rw)

pc-it-nico# mount /home/nico/fs2/home-13-Feb-2004.tar.crypt /tmp/ -o loop,encryption=blowfish Password:
ioctl: LOOP_SET_FD: Invalid argument

Yes, it is known. You can try the patch below.

I don't know if there is anything more to supporting sendfile than this. smb_file_sendfile follows the same pattern as the other smb_file_* operations.

/Urban

fs/smbfs/file.c +22 -0
diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/file.c linux-2.6.3-rc1-smbfs/fs/smbfs/file.c
@@ -257,6 +257,27 @@
 	return status;
 }
 
+static ssize_t
+smb_file_sendfile(struct file *file, loff_t *ppos,
+		  size_t count, read_actor_t actor, void __user *target)
+{
+	struct dentry *dentry = file->f_dentry;
+	ssize_t status;
+
+	VERBOSE("file %s/%s, pos=%Ld, count=%d\n",
+		DENTRY_PATH(dentry), *ppos, count);
+
+	status = smb_revalidate_inode(dentry);
+	if (status) {
+		PARANOIA("%s/%s validation failed, error=%d\n",
+			 DENTRY_PATH(dentry), status);
+		goto out;
+	}
+	status = generic_file_sendfile(file, ppos, count, actor, target);
+out:
+	return status;
+}
+
 /*
  * This does the "real" work of the write. The generic routine has
  * allocated the page, locked it, done all the page alignment stuff
@@ -388,6 +409,7 @@
 	.open		= smb_file_open,
 	.release	= smb_file_release,
 	.fsync		= smb_fsync,
+	.sendfile	= smb_file_sendfile,
 };
 
 struct inode_operations smb_file_inode_operations =
fs/smbfs/proc.c +0 -6
diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/proc.c linux-2.6.3-rc1-smbfs/fs/smbfs/proc.c
@@ -1015,12 +1015,6 @@
 	p += 19;
 	p += 8;
 
-	/* FIXME: the request will fail if the 'tid' is changed. This
-	   should perhaps be set just before transmitting ... */
-	WSET(req->rq_header, smb_tid, server->opt.tid);
-	WSET(req->rq_header, smb_pid, 1);
-	WSET(req->rq_header, smb_uid, server->opt.server_uid);
-
 	if (server->opt.protocol > SMB_PROTOCOL_CORE) {
 		int flags = SMB_FLAGS_CASELESS_PATHNAMES;
 		int flags2 = SMB_FLAGS2_LONG_PATH_COMPONENTS |
fs/smbfs/request.c +6 -0
diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/request.c linux-2.6.3-rc1-smbfs/fs/smbfs/request.c
@@ -384,6 +384,12 @@
 	struct smb_sb_info *server = req->rq_server;
 	int result;
 
+	if (req->rq_bytes_sent == 0) {
+		WSET(req->rq_header, smb_tid, server->opt.tid);
+		WSET(req->rq_header, smb_pid, 1);
+		WSET(req->rq_header, smb_uid, server->opt.server_uid);
+	}
+
 	result = smb_send_request(req);
 	if (result < 0 && result != -EAGAIN)
 		goto out;
fs/smbfs/smbiod.c +3 -0
diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/smbiod.c linux-2.6.3-rc1-smbfs/fs/smbfs/smbiod.c
@@ -161,6 +161,9 @@
 	while (head != &server->xmitq) {
 		req = list_entry(head, struct smb_request, rq_queue);
 		head = head->next;
+
+		WSET(req->rq_header, smb_uid, -1);
+		req->rq_bytes_sent = 0;
 		if (req->rq_flags & SMB_REQ_NORETRY) {
 			VERBOSE("aborting request %p on xmitq\n", req);
 			req->rq_errno = -EIO;
#2 lore raw

Works!
Will it be included into the main tree?

Nico

Urban Widmark [Mon, Feb 16, 2004 at 03:53:28PM +0100]:

Quoted 110 lines · Nico Schottelius
Quoted 7 lines

Hello!

While still suffering from my more or less dead harddisk I am seeing other nice problems. I copied my blowfish encrypted partition to a samba server. Now I want to mount it and use it:

Quoted 7 lines

pc-it-nico# mount
[...]
//fs2/home on /home/nico/fs2 type smbfs (rw)

pc-it-nico# mount /home/nico/fs2/home-13-Feb-2004.tar.crypt /tmp/ -o loop,encryption=blowfish Password:
ioctl: LOOP_SET_FD: Invalid argument

Yes, it is known. You can try the patch below.

I don't know if there is anything more to supporting sendfile than this. smb_file_sendfile follows the same pattern as the other smb_file_* operations.

/Urban

diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/file.c linux-2.6.3-rc1-smbfs/fs/smbfs/file.c

fs/smbfs/file.c +22 -0
@@ -257,6 +257,27 @@
 	return status;
 }
 
+static ssize_t
+smb_file_sendfile(struct file *file, loff_t *ppos,
+		  size_t count, read_actor_t actor, void __user *target)
+{
+	struct dentry *dentry = file->f_dentry;
+	ssize_t status;
+
+	VERBOSE("file %s/%s, pos=%Ld, count=%d\n",
+		DENTRY_PATH(dentry), *ppos, count);
+
+	status = smb_revalidate_inode(dentry);
+	if (status) {
+		PARANOIA("%s/%s validation failed, error=%d\n",
+			 DENTRY_PATH(dentry), status);
+		goto out;
+	}
+	status = generic_file_sendfile(file, ppos, count, actor, target);
+out:
+	return status;
+}
+
 /*
  * This does the "real" work of the write. The generic routine has
  * allocated the page, locked it, done all the page alignment stuff
@@ -388,6 +409,7 @@
 	.open		= smb_file_open,
 	.release	= smb_file_release,
 	.fsync		= smb_fsync,
+	.sendfile	= smb_file_sendfile,
 };
 
 struct inode_operations smb_file_inode_operations =

diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/proc.c linux-2.6.3-rc1-smbfs/fs/smbfs/proc.c

fs/smbfs/proc.c +0 -6
@@ -1015,12 +1015,6 @@
 	p += 19;
 	p += 8;
 
-	/* FIXME: the request will fail if the 'tid' is changed. This
-	   should perhaps be set just before transmitting ... */
-	WSET(req->rq_header, smb_tid, server->opt.tid);
-	WSET(req->rq_header, smb_pid, 1);
-	WSET(req->rq_header, smb_uid, server->opt.server_uid);
-
 	if (server->opt.protocol > SMB_PROTOCOL_CORE) {
 		int flags = SMB_FLAGS_CASELESS_PATHNAMES;
 		int flags2 = SMB_FLAGS2_LONG_PATH_COMPONENTS |

diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/request.c linux-2.6.3-rc1-smbfs/fs/smbfs/request.c

fs/smbfs/request.c +6 -0
@@ -384,6 +384,12 @@
 	struct smb_sb_info *server = req->rq_server;
 	int result;
 
+	if (req->rq_bytes_sent == 0) {
+		WSET(req->rq_header, smb_tid, server->opt.tid);
+		WSET(req->rq_header, smb_pid, 1);
+		WSET(req->rq_header, smb_uid, server->opt.server_uid);
+	}
+
 	result = smb_send_request(req);
 	if (result < 0 && result != -EAGAIN)
 		goto out;

diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/smbiod.c linux-2.6.3-rc1-smbfs/fs/smbfs/smbiod.c

fs/smbfs/smbiod.c +3 -0
@@ -161,6 +161,9 @@
 	while (head != &server->xmitq) {
 		req = list_entry(head, struct smb_request, rq_queue);
 		head = head->next;
+
+		WSET(req->rq_header, smb_uid, -1);
+		req->rq_bytes_sent = 0;
 		if (req->rq_flags & SMB_REQ_NORETRY) {
 			VERBOSE("aborting request %p on xmitq\n", req);
 			req->rq_errno = -EIO;
#3 lore raw
Quoted 2 lines · Nico Schottelius

Works!
Will it be included into the main tree?

Yes, unless someone complains.

Also, I'm waiting for feedback on the smb_uid part (that I didn't tell you about) so I don't think it will be in 2.6.3.

/Urban