From patchwork Fri Mar 29 06:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13610195 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57A91368 for ; Fri, 29 Mar 2024 06:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711693858; cv=none; b=URxhXqBHedEoDdx5xI+Gb6F5khrIY9/GGMc39dsr09Xcj2sGYz6m6QEupmxogWcGssAb13yhl8ypqQW4g0RFPw7N/4Y9tpudbmeAR51P5T+P+6hw7QT8AaAutXs3sAXW/yNb2Kw9eVaxt5oGc7sct1Z6AAInFVYBL3713g+kkmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711693858; c=relaxed/simple; bh=yefb00dYkOw4HUkVqK7aKYEePX0QeskAqyXWT3nV72E=; h=MIME-Version:From:Date:Message-ID:Subject:To:Content-Type; b=ontrSkaTGpdLx+wEuFmBXF9PBck+QBnbfjIh8lJypEg7BX1C3g0CVM3NmGvT8rn1PYDGR/PpOdM5Jtxq6SIcAUYKh/+1okj5DZYf7UkhOsz13eGS4st+ca+b6/uwPrFbn1sFzai9NmKpRkZ8gN/a4htu0gIK7S4gHcnMl2FWocE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Un6dT+s2; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Un6dT+s2" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-515c50dc2afso1802713e87.1 for ; Thu, 28 Mar 2024 23:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711693854; x=1712298654; darn=vger.kernel.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=M99wBygfGsxC5Fq3pgTqPVft4uFNhZ02XjuB4v30Nes=; b=Un6dT+s2so8b76afjxwSS5im8sTl+zkpKj1LllBIY/BUUBu6gL29bRD6p3aqFXAXeZ a3VASP5Lr6JERqT9mWIEuI0O01J/C+R0G/s1oIBYlPGyYJsl6Ku+rLgvPDJzJJj8fmw2 UKTQywZvcb/ed8HrteAjpDUOWwion+IvAVjDAu0ho2KkGtMlHGVmvqwcYObnbwdIOxdv 8SiVnuE9ArnNuOFl6VPw6qpHNYkyN1BzFALtxI4x7cOMqOe/pOVixWDVepcFhqAnifpH DpCQyJVLJyGl0ZfNfiqRAKtXye9qPd2K2gGVELM+TvAy0Ex5okYXiZJEAeQHWIVyx2ks m4OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711693854; x=1712298654; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=M99wBygfGsxC5Fq3pgTqPVft4uFNhZ02XjuB4v30Nes=; b=lmPb0CQJFfiRjhr6FHGZVEdfNrZrhYnTN4PcrX0QwRBUYCPY+6GC/+8Bsa9iW1Gssw AmQoNOfoxv+jLVnIhOSES5kQEl9/fzN0K6lKroHGvSHqFW5O1O3h34zGryHVrShjqnGG U5AAExVyEUd/SrVpuTWgsIQgolpdXowG8FRt6GesRLJ6BaXUMEY+oUvMWDEzcgQPayPZ +c2BReHTtSz4L73nVB7SBeFtKqYO7owxd77SdPelhkSpcfSKeUkTlgO9CNHJU8Vm6DOK kSb2j3wY5KHeMzLk2chAmY2CUolgMmvaRqQwXe4AfkgIWXatKWKWo5QP1/XlxxyU1uMk MI/Q== X-Gm-Message-State: AOJu0Yxrqexa9szFeKsNDTm5TG0aUwgfVWea8TJ1yTCyslnqVDJwrLpD 7vZk1/FXYUn4KrGjsOKV7dy+7aDgNxPxTQcwdmxdsV6ah6cF/yo+NZ+KwkAvcl0HVI7Che0q5Xg CB/fBt4VhD5QIRJcFSmzZ0hdC9J8XxMaQrbE= X-Google-Smtp-Source: AGHT+IFCrzw2EW7Rs5fpfTVOyMybC5a4YPCWuZtNq14XUWpTYFqCr/K3jGnGZLkLlCQxU0RnuREZWHmYfDOYVfR+ezc= X-Received: by 2002:ac2:4642:0:b0:515:b764:9057 with SMTP id s2-20020ac24642000000b00515b7649057mr1020533lfo.35.1711693853910; Thu, 28 Mar 2024 23:30:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Fri, 29 Mar 2024 01:30:42 -0500 Message-ID: Subject: [PATCH][WIP] populate superblock uuid at mount time To: CIFS , samba-technical , Namjae Jeon In order to get the unique id for the volume (the 8 byte VolumeSerialNumber) we need to issue a QUERY_INFO level 59 (FILE_ID_INFORMATION). Today we only query the older 4 byte (not guaranteed to be unique serial number). See section 2.4.21 of MS-FSCC. Looks like Samba and ksmbd do not support this info level though - although Windows does support it. Any thoughts on ksmbd or Samba support for FILE_ID_INFORMATION query? See attached work in progress patch From a5f90b46b17d20af4cdbfae6ac43dabc1e58e87e Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 29 Mar 2024 00:30:49 -0500 Subject: [PATCH] smb3: update sb uuid when full id information available Some servers like Windows and Azure report the larger (16 byte) unique volume serial number. For those that return full_id_information populate the sb->s_uuid This will also allow the new ioctl FS_IOC_GETFSUUID to work Signed-off-by: Steve French --- fs/smb/client/cifsfs.c | 2 ++ fs/smb/client/cifsglob.h | 1 + fs/smb/client/smb2ops.c | 2 ++ fs/smb/client/smb2pdu.c | 18 ++++++++++++++++++ fs/smb/client/smb2proto.h | 2 ++ 5 files changed, 25 insertions(+) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index aa6f1ecb7c0e..c6445f93d954 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -269,6 +269,8 @@ cifs_read_super(struct super_block *sb) goto out_no_root; } + if (tcon->vol_uuid != 0) + super_set_uuid(sb, (void *)&tcon->vol_uuid, sizeof(tcon->vol_uuid)); #ifdef CONFIG_CIFS_NFSD_EXPORT if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { cifs_dbg(FYI, "export ops supported\n"); diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 7ed9d05f6890..dae11166eb6f 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1264,6 +1264,7 @@ struct cifs_tcon { __u32 share_flags; __u32 maximal_access; __u32 vol_serial_number; + __u64 vol_uuid; /* full (64 bit, unique) serial number */ __le64 vol_create_time; __u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */ __u32 handle_timeout; /* persistent and durable handle timeout in ms */ diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 2ed456948f34..84d2f3f1c89a 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -831,6 +831,8 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, if (rc) return; + SMB2_get_vol_serial_num(xid, tcon, fid.persistent_fid, fid.volatile_fid); + SMB3_request_interfaces(xid, tcon, true /* called during mount */); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 3ea688558e6c..f262b8251b2e 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -3908,6 +3908,24 @@ SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, SMB2_MAX_BUFFER_SIZE, MIN_SEC_DESC_LEN, data, plen); } +int +SMB2_get_vol_serial_num(const unsigned int xid, struct cifs_tcon *tcon, + u64 persistent_fid, u64 volatile_fid) +{ + int rc; + struct smb2_file_id_information vol_info; + + rc = query_info(xid, tcon, persistent_fid, volatile_fid, + FILE_ID_INFORMATION, SMB2_O_INFO_FILE, 0, + sizeof(struct smb2_file_id_information), + sizeof(struct smb2_file_id_information), + (void **)&vol_info, NULL); + if (!rc) + tcon->vol_uuid = le64_to_cpu(vol_info.VolumeSerialNumber); + + return rc; +} + int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid) diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h index 732169d8a67a..b518f1fdedcf 100644 --- a/fs/smb/client/smb2proto.h +++ b/fs/smb/client/smb2proto.h @@ -207,6 +207,8 @@ extern void SMB2_query_info_free(struct smb_rqst *rqst); extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id, void **data, unsigned int *plen, u32 info); +extern int SMB2_get_vol_serial_num(const unsigned int xid, struct cifs_tcon *tcon, + u64 persistent_fid, u64 volatile_fid); extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid); -- 2.40.1