lustre: missing updates from lustre 2.9
cover lustre: missing updates from lustre 2.9
This patch set fills in the known missing pieces from the Lustre 2.9 release. With these patches this brings us to the pre-2.10 development cycle. The grant allocation fixes were missing as well as security hole closes. The rest are small changes in addition to support for filesets and ladvise feature.
Alexander Boyko (1):
lustre: obd: add callback for llog_cat_process_or_fork
Bobi Jam (1):
lustre: osc: max_pages_per_rpc should be chunk size aligned
Fan Yong (1):
lustre: ptlrpc: properly set "rq_xid" for 4MB IO
Henri Doreau (1):
lustre: llite: restore fd_och when putting lease
James Simmons (2):
lustre: libcfs: restore original behavior in cfs_str2num_check
lustre: update version to 2.8.99
Jian Yu (1):
lustre: mount: fix lmd_parse() to handle new delimiters
Jinshan Xiong (1):
lustre: llite: fast read implementation
Johann Lombardi (1):
lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
John L. Hammond (3):
lustre: obd: rename md_getstatus() to md_get_root()
lustre: obd: reserve connection flag OBD_CONNECT2_FILE_SECCTX
lustre: security: send file security context for creates
Lai Siyao (1):
lustre: fileset: add fileset mount support
Li Xi (3):
lustre: ladvise: Add feature of giving file access advices
lustre: ladvise: Add willread advice support for ladvise
lustre: ladvise: Add dontneed advice support for ladvise
Niu Yawei (1):
lustre: ldlm: reduce mem footprint of ldlm_resource
Patrick Farrell (1):
lustre: llite: ladvise protocol changes
.../lustre/include/uapi/linux/lustre/lustre_idl.h | 52 ++- .../lustre/include/uapi/linux/lustre/lustre_user.h | 51 +++ .../lustre/include/uapi/linux/lustre/lustre_ver.h | 4 +- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 17 +- drivers/staging/lustre/lustre/include/cl_object.h | 13 + .../staging/lustre/lustre/include/lustre_disk.h | 2 + drivers/staging/lustre/lustre/include/lustre_dlm.h | 24 +- .../staging/lustre/lustre/include/lustre_import.h | 1 + .../lustre/lustre/include/lustre_req_layout.h | 10 +- .../staging/lustre/lustre/include/lustre_swab.h | 2 + drivers/staging/lustre/lustre/include/obd.h | 17 +- drivers/staging/lustre/lustre/include/obd_class.h | 16 +- .../staging/lustre/lustre/include/obd_support.h | 5 +- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 20 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 32 +- drivers/staging/lustre/lustre/llite/dir.c | 54 +++- drivers/staging/lustre/lustre/llite/file.c | 360 ++++++++++++++++++--- .../staging/lustre/lustre/llite/llite_internal.h | 34 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 37 ++- drivers/staging/lustre/lustre/llite/llite_mmap.c | 34 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 38 +++ drivers/staging/lustre/lustre/llite/namei.c | 40 ++- drivers/staging/lustre/lustre/llite/rw.c | 68 +++- drivers/staging/lustre/lustre/llite/vvp_internal.h | 1 + drivers/staging/lustre/lustre/llite/vvp_io.c | 3 + .../staging/lustre/lustre/llite/xattr_security.c | 38 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 34 +- drivers/staging/lustre/lustre/lov/lov_io.c | 28 ++ drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 + drivers/staging/lustre/lustre/mdc/mdc_lib.c | 32 ++ drivers/staging/lustre/lustre/mdc/mdc_locks.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_reint.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_request.c | 50 ++- drivers/staging/lustre/lustre/obdclass/cl_io.c | 2 + drivers/staging/lustre/lustre/obdclass/llog_cat.c | 16 +- .../lustre/lustre/obdclass/lprocfs_status.c | 72 ++++- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 135 +++++++- drivers/staging/lustre/lustre/osc/lproc_osc.c | 18 ++ drivers/staging/lustre/lustre/osc/osc_cache.c | 95 ++++-- .../staging/lustre/lustre/osc/osc_cl_internal.h | 1 + drivers/staging/lustre/lustre/osc/osc_dev.c | 1 + drivers/staging/lustre/lustre/osc/osc_internal.h | 4 + drivers/staging/lustre/lustre/osc/osc_io.c | 79 +++++ drivers/staging/lustre/lustre/osc/osc_request.c | 184 +++++++++-- drivers/staging/lustre/lustre/ptlrpc/client.c | 9 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 10 + drivers/staging/lustre/lustre/ptlrpc/layout.c | 66 +++- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 3 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 27 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 122 +++++-- 52 files changed, 1722 insertions(+), 259 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
From: Johann Lombardi <[email protected]>
Add support for grant overhead calculation on the client side. To do so, clients track usage on a per-extent basis. An extent is composed of contiguous blocks.
The OST now returns to the OSC layer several parameters to consume grant more accurately:
- the backend filesystem block size which is the minimal grant allocation unit;
- the maximum extent size;
- the extent insertion cost.
Clients now pack in bulk write how much grant space was consumed for the RPC. Dirty data accounting also adopts the same scheme.
Moreover, each backend OSD now reports its own set of parameters:
- For ldiskfs, we usually have a 4KB block size with a maximum extent size of 32MB (theoretical limit of 128MB) and an extent insertion cost of 6 x 4KB = 24KB
- For ZFS, we report a block size of 128KB, an extent size of 128 blocks (i.e. 16MB with 128KB block size) and a block insertion cost of 112KB.
Besides, there is now no more generic metadata overhead reservation done inside each OSD. Instead grant space is inflated for clients that do not support the new grant parameters. That said, a tiny percentage (typically 0.76%) of the free space is still reserved inside each OSD to avoid fragmentation which might hurt performance and impact our grant calculation (e.g. extents are broken due to fragmentation).
This patch also fixes several other issues:
- Bulk write resent by ptlrpc after reconnection could trigger spurious error messages related to broken dirty accounting. The issue was that oa_dirty is discarded for resent requests (grant flag cleared in ost_brw_write()), so we can legitimately have grant > fed_dirty in ofd_grant_check().
This was fixed by resetting fed_dirty on reconnection and skipping the dirty accounting check in ofd_grant_check() in the case of ptlrpc resend.
- In obd_connect_data_seqprint(), the connection flags cannot fit in a 32-bit integer.
- When merging two OSC extents, an extent tax should be released in both the merged extent and in the grant accounting.
WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793
--- .../lustre/include/uapi/linux/lustre/lustre_idl.h | 8 +- drivers/staging/lustre/lustre/include/obd.h | 9 ++- .../staging/lustre/lustre/include/obd_support.h | 1 + drivers/staging/lustre/lustre/llite/llite_lib.c | 9 +++ .../lustre/lustre/obdclass/lprocfs_status.c | 10 ++- drivers/staging/lustre/lustre/osc/lproc_osc.c | 18 +++++ drivers/staging/lustre/lustre/osc/osc_cache.c | 84 +++++++++++++++------ drivers/staging/lustre/lustre/osc/osc_request.c | 85 ++++++++++++++++------ .../staging/lustre/lustre/ptlrpc/pack_generic.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 32 ++++---- 10 files changed, 191 insertions(+), 69 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +4 -4
@@ -732,10 +732,10 @@ struct obd_connect_data {__u32 ocd_index;/* LOV index to connect to */ __u32 ocd_brw_size;/* Maximum BRW size in bytes */ __u64 ocd_ibits_known;/* inode bits this client understands */ -__u8 ocd_blocksize;/* log2 of the backend filesystem blocksize */ -__u8 ocd_inodespace;/* log2 of the per-inode space consumption */ -__u16 ocd_grant_extent;/* per-extent grant overhead, in 1K blocks */ -__u32 ocd_unused;/* also fix lustre_swab_connect */ +__u8 ocd_grant_blkbits;/* log2 of the backend filesystem blocksize */ +__u8 ocd_grant_inobits;/* log2 of the per-inode space consumption */ +__u16 ocd_grant_tax_kb;/* extent grant overhead, in 1K blocks */ +__u32 ocd_grant_max_blks;/* maximum number of blocks per extent */ __u64 ocd_transno;/* first transno from client to be replayed */ __u32 ocd_group;/* MDS group on OST */ __u32 ocd_cksum_types;/* supported checksum algorithms */
drivers/staging/lustre/lustre/include/obd.h +8 -1
@@ -198,6 +198,8 @@ struct client_obd {unsigned long cl_dirty_transit;/* dirty synchronous */ unsigned long cl_avail_grant;/* bytes of credit for ost */ unsigned long cl_lost_grant;/* lost credits (trunc) */ +/* grant consumed for dirty pages */ +unsigned long cl_dirty_grant;/* since we allocate grant by blocks, we don't know how many grant will * be used to add a page into cache. As a solution, we reserve maximum
@@ -214,7 +216,12 @@ struct client_obd {* the extent size. A chunk is max(PAGE_SIZE, OST block size) */ int cl_chunkbits; -unsigned int cl_extent_tax;/* extent overhead, by bytes */ +/* extent insertion metadata overhead to be accounted in grant, +* in bytes +*/ +unsigned int cl_grant_extent_tax; +/* maximum extent size, in number of pages */ +unsigned int cl_max_extent_pages;/* keep track of objects that have lois that contain pages which * have been queued for async brw. this lock also protects the
drivers/staging/lustre/lustre/include/obd_support.h +1 -0
@@ -320,6 +320,7 @@#define OBD_FAIL_OSC_CP_ENQ_RACE 0x410#define OBD_FAIL_OSC_NO_GRANT 0x411#define OBD_FAIL_OSC_DELAY_SETTIME 0x412 +#define OBD_FAIL_OSC_CONNECT_GRANT_PARAM 0x413#define OBD_FAIL_OSC_DELAY_IO 0x414#define OBD_FAIL_PTLRPC 0x500
drivers/staging/lustre/lustre/llite/llite_lib.c +9 -0
@@ -178,6 +178,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)return -ENOMEM ; } +/* +* pass client page size via ocd_grant_blkbits, the server should report +* back its backend blocksize for grant calculation purpose +*/ + data->ocd_grant_blkbits =PAGE_SHIFT ; +/* indicate the features supported by this client */ data->ocd_connect_flags =OBD_CONNECT_IBITS |OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID |
@@ -367,6 +373,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)OBD_CONNECT_PINGLESS |OBD_CONNECT_LFSCK |OBD_CONNECT_BULK_MBITS ; +if (!OBD_FAIL_CHECK (OBD_FAIL_OSC_CONNECT_GRANT_PARAM )) + data->ocd_connect_flags |=OBD_CONNECT_GRANT_PARAM ; +if (!OBD_FAIL_CHECK (OBD_FAIL_OSC_CONNECT_CKSUM )) {/* OBD_CONNECT_CKSUM should always be set, even if checksums are * disabled by default, because it can still be enabled on the
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +6 -4
@@ -163,10 +163,12 @@ static void obd_connect_data_seqprint(struct seq_file *m,if (flags &OBD_CONNECT_GRANT_PARAM )seq_printf (m," grant_block_size: %d\n" " grant_inode_size: %d\n" -" grant_extent_overhead: %d\n" , - ocd->ocd_blocksize, - ocd->ocd_inodespace, - ocd->ocd_grant_extent); +" grant_max_extent_size: %d\n" +" grant_extent_tax: %d\n" , +1 << ocd->ocd_grant_blkbits, +1 << ocd->ocd_grant_inobits, + ocd->ocd_grant_max_blks << ocd->ocd_grant_blkbits, + ocd->ocd_grant_tax_kb <<10 );if (flags &OBD_CONNECT_TRANSNO )seq_printf (m," first_transno: %llx\n" , ocd->ocd_transno);
drivers/staging/lustre/lustre/osc/lproc_osc.c +18 -0
@@ -326,6 +326,23 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, }LUSTRE_RO_ATTR (cur_lost_grant_bytes); +static ssize_t cur_dirty_grant_bytes_show (struct kobject *kobj, +struct attribute *attr, +char *buf) +{ + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); +struct client_obd *cli = &dev->u.cli; +int len; + +spin_lock (&cli->cl_loi_list_lock); + len =sprintf (buf,"%lu\n" , cli->cl_dirty_grant); +spin_unlock (&cli->cl_loi_list_lock); + +return len; +} +LUSTRE_RO_ATTR (cur_dirty_grant_bytes); +static ssize_t grant_shrink_interval_show (struct kobject *kobj,struct attribute *attr,char *buf)
@@ -817,6 +834,7 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_cur_dirty_bytes.attr, &lustre_attr_cur_grant_bytes.attr, &lustre_attr_cur_lost_grant_bytes.attr, + &lustre_attr_cur_dirty_grant_bytes.attr, &lustre_attr_destroys_in_flight.attr, &lustre_attr_grant_shrink_interval.attr, &lustre_attr_lockless_truncate.attr,
drivers/staging/lustre/lustre/osc/osc_cache.c +63 -21
234 lines not on this page · raw message
drivers/staging/lustre/lustre/osc/osc_request.c +64 -21
133 lines not on this page · raw message
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +2 -2
@@ -1551,8 +1551,8 @@ void lustre_swab_connect(struct obd_connect_data *ocd)/* ocd_blocksize and ocd_inodespace don't need to be swabbed because * they are 8-byte values */ -__swab16s (&ocd->ocd_grant_extent); -__swab32s (&ocd->ocd_unused); +__swab16s (&ocd->ocd_grant_tax_kb); +__swab32s (&ocd->ocd_grant_max_blks);__swab64s (&ocd->ocd_transno);__swab32s (&ocd->ocd_group);__swab32s (&ocd->ocd_cksum_types);
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +16 -16
@@ -884,22 +884,22 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_connect_data, ocd_ibits_known));LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_ibits_known) ==8 ,"found %lld\n" , (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_ibits_known)); -LASSERTF ((int )offsetof(struct obd_connect_data , ocd_blocksize) ==32 ,"found %lld\n" , - (long long )(int )offsetof(struct obd_connect_data , ocd_blocksize)); -LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_blocksize) ==1 ,"found %lld\n" , - (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_blocksize)); -LASSERTF ((int )offsetof(struct obd_connect_data , ocd_inodespace) ==33 ,"found %lld\n" , - (long long )(int )offsetof(struct obd_connect_data , ocd_inodespace)); -LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_inodespace) ==1 ,"found %lld\n" , - (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_inodespace)); -LASSERTF ((int )offsetof(struct obd_connect_data , ocd_grant_extent) ==34 ,"found %lld\n" , - (long long )(int )offsetof(struct obd_connect_data , ocd_grant_extent)); -LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_extent) ==2 ,"found %lld\n" , - (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_extent)); -LASSERTF ((int )offsetof(struct obd_connect_data , ocd_unused) ==36 ,"found %lld\n" , - (long long )(int )offsetof(struct obd_connect_data , ocd_unused)); -LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_unused) ==4 ,"found %lld\n" , - (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_unused)); +LASSERTF ((int )offsetof(struct obd_connect_data , ocd_grant_blkbits) ==32 ,"found %lld\n" , + (long long )(int )offsetof(struct obd_connect_data , ocd_grant_blkbits)); +LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_blkbits) ==1 ,"found %lld\n" , + (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_blkbits)); +LASSERTF ((int )offsetof(struct obd_connect_data , ocd_grant_inobits) ==33 ,"found %lld\n" , + (long long )(int )offsetof(struct obd_connect_data , ocd_grant_inobits)); +LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_inobits) ==1 ,"found %lld\n" , + (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_inobits)); +LASSERTF ((int )offsetof(struct obd_connect_data , ocd_grant_tax_kb) ==34 ,"found %lld\n" , + (long long )(int )offsetof(struct obd_connect_data , ocd_grant_tax_kb)); +LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_tax_kb) ==2 ,"found %lld\n" , + (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_tax_kb)); +LASSERTF ((int )offsetof(struct obd_connect_data , ocd_grant_max_blks) ==36 ,"found %lld\n" , + (long long )(int )offsetof(struct obd_connect_data , ocd_grant_max_blks)); +LASSERTF ((int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_max_blks) ==4 ,"found %lld\n" , + (long long )(int )sizeof (((struct obd_connect_data *)0 )->ocd_grant_max_blks));LASSERTF ((int )offsetof(struct obd_connect_data , ocd_transno) ==40 ,"found %lld\n" , (long long )(int )offsetof(struct obd_connect_data , ocd_transno)); LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_transno) == 8, "found %lld\n",
Signature · 1 line
1.8.3.1
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Quoted 7 lines · James Simmons
From: Johann Lombardi <[email protected]>
Add support for grant overhead calculation on the client side. To do so, clients track usage on a per-extent basis. An extent is composed of contiguous blocks.
The OST now returns to the OSC layer several parameters to consume grant more accurately:
Just to be sure that I'm understanding correctly, should "consume" above be "compute" ??
Quoted 26 lines
- the backend filesystem block size which is the minimal grant allocation unit;
- the maximum extent size;
- the extent insertion cost.
Clients now pack in bulk write how much grant space was consumed for the RPC. Dirty data accounting also adopts the same scheme.Moreover, each backend OSD now reports its own set of parameters:
- For ldiskfs, we usually have a 4KB block size with a maximum extent size of 32MB (theoretical limit of 128MB) and an extent insertion cost of 6 x 4KB = 24KB
- For ZFS, we report a block size of 128KB, an extent size of 128 blocks (i.e. 16MB with 128KB block size) and a block insertion cost of 112KB.Besides, there is now no more generic metadata overhead reservation done inside each OSD. Instead grant space is inflated for clients that do not support the new grant parameters. That said, a tiny percentage (typically 0.76%) of the free space is still reserved inside each OSD to avoid fragmentation which might hurt performance and impact our grant calculation (e.g. extents are broken due to fragmentation).
This patch also fixes several other issues:
Quoted 8 lines
- Bulk write resent by ptlrpc after reconnection could trigger spurious error messages related to broken dirty accounting. The issue was that
oa_dirtyis discarded for resent requests (grant flag cleared inost_brw_write()), so we can legitimately have grant >fed_dirtyinofd_grant_check().
This was fixed by resettingfed_dirtyon reconnection and skipping the dirty accounting check inofd_grant_check()in the case of ptlrpc resend.
ofd_grant_check doesn't appear in this patch. Presumably it was part of the server code that was stripped from the patch.
Quoted 3 lines
- In
obd_connect_data_seqprint(), the connection flags cannot fit in a 32-bit integer.
I cannot see what this might refer to either.
Quoted 3 lines
- When merging two OSC extents, an extent tax should be released in both the merged extent and in the grant accounting.
I think I might see what this relates to.
drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, · line 340
Quoted 12 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +12
-0+static ssize_t cur_dirty_grant_bytes_show (struct kobject *kobj, +struct attribute *attr, +char *buf) +{ + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); +struct client_obd *cli = &dev->u.cli; +int len; + +spin_lock (&cli->cl_loi_list_lock); + len =sprintf (buf,"%lu\n" , cli->cl_dirty_grant); +spin_unlock (&cli->cl_loi_list_lock);
Why take the spinlock?? cl_dirty_grant is 'long', so reading it is atomic.
drivers/staging/lustre/lustre/osc/osc_request.c static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, · line 622
Quoted 10 lines
drivers/staging/lustre/lustre/osc/osc_request.c +10
-0+if (OCD_HAS_FLAG (&cli->cl_import->imp_connect_data, +GRANT_PARAM )) { +int nrextents; + +/* +* take extent tax into account when asking for more +* grant space +*/ + nrextents = (nrpages + cli->cl_max_extent_pages -1 ) / + cli->cl_max_extent_pages;
I generally prefer DIV_ROUND_UP() for this.
I don't think any of the above will stop me from applying the patch, though I might edit the description, and may add a fix-up patch afterwards.
Thanks.
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/348eec1f/attachment.sig>
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Neil,
Compute vs consume: Honestly either would work. The client consumes grant when it writes data, this fix to the calculation allows it to consume more accurately. *shrugs*
- Patrick
________________________________
From: lustre-devel <[email protected]> on behalf of NeilBrown <[email protected]>
Sent: Monday, July 2, 2018 10:04:48 PM
To: James Simmons; Andreas Dilger; Oleg Drokin
Cc: Johann Lombardi; Lustre Development List
Subject: Re: [lustre-devel] [PATCH 01/18] lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Quoted 7 lines · James Simmons
From: Johann Lombardi <[email protected]>
Add support for grant overhead calculation on the client side. To do so, clients track usage on a per-extent basis. An extent is composed of contiguous blocks.
The OST now returns to the OSC layer several parameters to consume grant more accurately:
Just to be sure that I'm understanding correctly, should "consume" above be "compute" ??
Quoted 26 lines
- the backend filesystem block size which is the minimal grant allocation unit;
- the maximum extent size;
- the extent insertion cost.
Clients now pack in bulk write how much grant space was consumed for the RPC. Dirty data accounting also adopts the same scheme.Moreover, each backend OSD now reports its own set of parameters:
- For ldiskfs, we usually have a 4KB block size with a maximum extent size of 32MB (theoretical limit of 128MB) and an extent insertion cost of 6 x 4KB = 24KB
- For ZFS, we report a block size of 128KB, an extent size of 128 blocks (i.e. 16MB with 128KB block size) and a block insertion cost of 112KB.Besides, there is now no more generic metadata overhead reservation done inside each OSD. Instead grant space is inflated for clients that do not support the new grant parameters. That said, a tiny percentage (typically 0.76%) of the free space is still reserved inside each OSD to avoid fragmentation which might hurt performance and impact our grant calculation (e.g. extents are broken due to fragmentation).
This patch also fixes several other issues:
Quoted 8 lines
- Bulk write resent by ptlrpc after reconnection could trigger spurious error messages related to broken dirty accounting. The issue was that
oa_dirtyis discarded for resent requests (grant flag cleared inost_brw_write()), so we can legitimately have grant >fed_dirtyinofd_grant_check().
This was fixed by resettingfed_dirtyon reconnection and skipping the dirty accounting check inofd_grant_check()in the case of ptlrpc resend.
ofd_grant_check doesn't appear in this patch. Presumably it was part of the server code that was stripped from the patch.
Quoted 3 lines
- In
obd_connect_data_seqprint(), the connection flags cannot fit in a 32-bit integer.
I cannot see what this might refer to either.
Quoted 3 lines
- When merging two OSC extents, an extent tax should be released in both the merged extent and in the grant accounting.
I think I might see what this relates to.
drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, · line 340
Quoted 12 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +12
-0+static ssize_t cur_dirty_grant_bytes_show (struct kobject *kobj, +struct attribute *attr, +char *buf) +{ + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); +struct client_obd *cli = &dev->u.cli; +int len; + +spin_lock (&cli->cl_loi_list_lock); + len =sprintf (buf,"%lu\n" , cli->cl_dirty_grant); +spin_unlock (&cli->cl_loi_list_lock);
Why take the spinlock?? cl_dirty_grant is 'long', so reading it is atomic.
drivers/staging/lustre/lustre/osc/osc_request.c static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, · line 622
Quoted 10 lines
drivers/staging/lustre/lustre/osc/osc_request.c +10
-0+if (OCD_HAS_FLAG (&cli->cl_import->imp_connect_data, +GRANT_PARAM )) { +int nrextents; + +/* +* take extent tax into account when asking for more +* grant space +*/ + nrextents = (nrpages + cli->cl_max_extent_pages -1 ) / + cli->cl_max_extent_pages;
I generally prefer DIV_ROUND_UP() for this.
I don't think any of the above will stop me from applying the patch, though I might edit the description, and may add a fix-up patch afterwards.
Thanks.
NeilBrown
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/dc5329ff/attachment-0001.html>
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Quoted 3 lines · Patrick Farrell
Neil,
Compute vs consume: Honestly either would work. The client consumes grant when it writes data, this fix to the calculation allows it to consume more accurately. *shrugs*
Good - thanks.
I would have said "this fix to the calculation allows it to track what it has consumed more accurately", but it is a small point. I just wanted to be sure I understood, and now I'm sure I do.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180704/a4870fe1/attachment.sig>
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
In reply to James SimmonsJames,
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793
James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be https://jira.whamcloud.com/browse/LU-2049 .
Thanks,
-Cory
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Quoted 8 lines
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
Signed-off-by Johann Lombardi <[email protected]>Signed-off-by Jinshan Xiong <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793
Quoted 8 lines
Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Nathaniel Clark <[email protected]>James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be
https://jira.whamcloud.com/browse/LU-2049 .
This is tricky one. The reason I updated the email address to avoid bouncing emails. Also this allows the original author the change to still reply. Does that seem reasonable? It is still in the air for some people what their email address is to me. Ah you are right I dropped the s. Its should be https://jira.whamcloud.com/....
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
In reply to Cory SpitzQuoted 8 lines
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
Signed-off-by Johann Lombardi <[email protected]>Signed-off-by Jinshan Xiong <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793
Quoted 8 lines
Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Nathaniel Clark <[email protected]>James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be
https://jira.whamcloud.com/browse/LU-2049 .
This is tricky one. The reason I updated the email address to avoid bouncing emails. Also this allows the original author the chance to still reply. Does that seem reasonable? It is still in the air for some people what their email address is to me. Ah you are right I dropped the s. Its should be https://jira.whamcloud.com/....
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
And Johann is still at Intel...
Cheers, Andreas
Quoted 24 lines · James Simmons
Quoted 9 lines
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
Signed-off-by Johann Lombardi <[email protected]>Signed-off-by Jinshan Xiong <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793Quoted 8 lines
Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Nathaniel Clark <[email protected]>James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be
https://jira.whamcloud.com/browse/LU-2049 .This is tricky one. The reason I updated the email address to avoid bouncing emails. Also this allows the original author the chance to still reply. Does that seem reasonable? It is still in the air for some people what their email address is to me. Ah you are right I dropped the s. Its should be https://jira.whamcloud.com/....
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
Quoted 2 lines
And Johann is still at Intel...
Its hard to tell. Is this true for WangDi and Fan Young as well?
Quoted 25 lines
Quoted 24 lines · James Simmons
Quoted 9 lines
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
Signed-off-by Johann Lombardi <[email protected]>Signed-off-by Jinshan Xiong <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793Quoted 8 lines
Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Nathaniel Clark <[email protected]>James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be
https://jira.whamcloud.com/browse/LU-2049 .This is tricky one. The reason I updated the email address to avoid bouncing emails. Also this allows the original author the chance to still reply. Does that seem reasonable? It is still in the air for some people what their email address is to me. Ah you are right I dropped the s. Its should be https://jira.whamcloud.com/....
PATCH 1/18 lustre: grant: add support for OBD_CONNECT_GRANT_PARAM
In reply to James SimmonsQuoted 10 lines · James Simmons
Quoted 10 lines
?On 7/2/18, 6:25 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of [email protected]> wrote:
From: Johann Lombardi <[email protected]>
Signed-off-by Johann Lombardi <[email protected]>Signed-off-by Jinshan Xiong <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/2049
Reviewed-on: http://review.whamcloud.com/7793Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Nathaniel Clark <[email protected]>
Quoted 8 lines
Quoted 5 lines
James, can you fix this up? I'm not sure how historical patches should be attributed, but Johann's address seems wrong.
From should be attributed to Johann Lombardi <[email protected]> . Also, the Bug URL should be
https://jira.whamcloud.com/browse/LU-2049 .This is tricky one. The reason I updated the email address to avoid bouncing emails.
I would recommend never trying to update email addresses. The kernel history is full of addresses that are no longer valid. Discussion of patches should happen on lists, and interested parties should subscribe to the lists. If someone wants to particularly see emails sent to some old address of their's it should be easy enough to add some filtering. If you particularly want to contact the author of some old patch, it is unlikely to take to much searching to find a valid address (just ask on the email list - someone is bound to know).
Bounces are a little bit annoying, but so is spam - we just learn ways to deal with it.
For this particular patch I've restored the addresses from the original patch, even though I know some of them are no longer valid. They were valid when the review was done, and the effectively give credit to the company which paid for the review. I won't bother the rest though.
Thanks,
NeilBrown
Quoted 4 lines
Also this allows the original author the chance to still reply. Does that seem reasonable? It is still in the air for some people what their email address is to me. Ah you are right I dropped the s. Its should be https://jira.whamcloud.com/....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180723/2d64cee1/attachment.sig>
PATCH 2/18 lustre: ladvise: Add feature of giving file access advices
In reply to James SimmonsFrom: Li Xi <[email protected]>
The fadvise() system call provided by Linux kernel enables applications to give advices or hints about how a file will be accessed. However, It is only a client side mechanism which is not enough for distributed file systems like Lustre, because in order to tune system-wide cache or read-ahead policies, servers need to understand the advices too.
This patch adds a new feature named ladvise which provides new APIs and utils to give advices about the access pattern of Lustre files with the purpose of performance improvement. It is similar to Linux fadvise() system call, except it forwards the advices directly from Lustre client to server. The server side codes will apply appropriate read-ahead and caching techniques for the corresponding files.
A typical workload for ladvise is e.g. a bunch of different clients are doing small random reads of a file, so prefetching pages into OSS cache with big linear reads before the random IO is a net benefit. Fetching all that data into each client cache with fadvise() may not be, due to much more data being sent to the client.
WC-bug-id: https://jira.whamcloud.com/browse/LU-4931
Reviewed-on: http://review.whamcloud.com/10029
--- .../lustre/include/uapi/linux/lustre/lustre_idl.h | 3 +- .../lustre/include/uapi/linux/lustre/lustre_user.h | 32 +++++++ drivers/staging/lustre/lustre/include/cl_object.h | 13 +++ .../lustre/lustre/include/lustre_req_layout.h | 4 + .../staging/lustre/lustre/include/lustre_swab.h | 2 + drivers/staging/lustre/lustre/llite/file.c | 106 +++++++++++++++++++++ drivers/staging/lustre/lustre/llite/vvp_io.c | 3 + drivers/staging/lustre/lustre/lov/lov_io.c | 28 ++++++ drivers/staging/lustre/lustre/obdclass/cl_io.c | 2 + .../staging/lustre/lustre/osc/osc_cl_internal.h | 1 + drivers/staging/lustre/lustre/osc/osc_dev.c | 1 + drivers/staging/lustre/lustre/osc/osc_internal.h | 4 + drivers/staging/lustre/lustre/osc/osc_io.c | 79 +++++++++++++++ drivers/staging/lustre/lustre/osc/osc_request.c | 94 ++++++++++++++++++ drivers/staging/lustre/lustre/ptlrpc/layout.c | 24 +++++ .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 1 + .../staging/lustre/lustre/ptlrpc/pack_generic.c | 19 ++++ drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 54 ++++++++++- 18 files changed, 468 insertions(+), 2 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +2 -1
@@ -812,7 +812,8 @@ enum ost_cmd {OST_QUOTACHECK =18 ,/* not used since 2.4 */ OST_QUOTACTL =19 ,OST_QUOTA_ADJUST_QUNIT =20 ,/* not used since 2.4 */ - OST_LAST_OPC +OST_LADVISE =21 , + OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */ };#define OST_FIRST_OPC OST_REPLY
drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +32 -0
@@ -276,6 +276,7 @@ struct ost_id {#define LL_IOC_MIGRATE _IOR('f', 247, int)#define LL_IOC_FID2MDTIDX _IOWR('f', 248, struct lu_fid)#define LL_IOC_GETPARENT _IOWR('f', 249, struct getparent) +#define LL_IOC_LADVISE _IOR('f', 250, struct lu_ladvise)/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */ enum ll_lease_type {
@@ -1322,6 +1323,37 @@ struct hsm_copy { struct hsm_action_item hc_hai; }; +enum lu_ladvise_type { +LU_LADVISE_INVALID =0 , +}; + +#define LU_LADVISE_NAMES { } + +struct lu_ladvise { +__u64 lla_advice; +__u64 lla_start; +__u64 lla_end; +__u64 lla_padding; +}; + +enum ladvise_flag { +LF_ASYNC =0x00000001 , +}; + +#define LADVISE_MAGIC 0x1ADF1CE0 +#define LF_MASK LF_ASYNC + +struct ladvise_hdr { +__u32 lah_magic;/* LADVISE_MAGIC */ +__u32 lah_count;/* number of advices */ +__u64 lah_flags;/* from enum ladvise_flag */ +__u64 lah_padding1;/* unused */ +__u64 lah_padding2;/* unused */ +struct lu_ladvise lah_advise[0 ]; +}; + +#define LAH_COUNT_MAX 1024 +/** @} lustreuser */ #endif /* _LUSTRE_USER_H */
drivers/staging/lustre/lustre/include/cl_object.h +13 -0
@@ -1394,6 +1394,11 @@ enum cl_io_type {* cl_io_loop() is never called for it. */ CIT_MISC , +/** +* ladvise handling +* To give advice about access of a file +*/ +CIT_LADVISE , CIT_OP_NR };
@@ -1804,6 +1809,14 @@ struct cl_io {/* how many pages were written/discarded */ unsigned int fi_nr_written; } ci_fsync; +struct cl_ladvise_io { +u64 li_start; +u64 li_end; +/** file system level fid */ +struct lu_fid *li_fid; +enum lu_ladvise_type li_advice; +u64 li_flags; + } ci_ladvise; } u;struct cl_2queue ci_queue;size_t ci_nob;
drivers/staging/lustre/lustre/include/lustre_req_layout.h +4 -0
@@ -190,6 +190,7 @@ void req_capsule_shrink(struct req_capsule *pill,extern struct req_format RQF_OST_GET_INFO_LAST_FID ;extern struct req_format RQF_OST_SET_INFO_LAST_FID ;extern struct req_format RQF_OST_GET_INFO_FIEMAP ; +extern struct req_format RQF_OST_LADVISE ;/* LDLM req_format */ extern struct req_format RQF_LDLM_ENQUEUE ;
@@ -299,6 +300,9 @@ void req_capsule_shrink(struct req_capsule *pill,extern struct req_msg_field RMF_MGS_CONFIG_BODY ;extern struct req_msg_field RMF_MGS_CONFIG_RES ; +extern struct req_msg_field RMF_OST_LADVISE_HDR ; +extern struct req_msg_field RMF_OST_LADVISE ; +/* generic uint32 */ extern struct req_msg_field RMF_U32 ;
drivers/staging/lustre/lustre/include/lustre_swab.h +2 -0
@@ -99,6 +99,8 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,void lustre_swab_swap_layouts (struct mdc_swap_layouts *msl);void lustre_swab_close_data (struct close_data *data);void lustre_swab_lmv_user_md (struct lmv_user_md *lum); +void lustre_swab_ladvise (struct lu_ladvise *ladvise); +void lustre_swab_ladvise_hdr (struct ladvise_hdr *ladvise_hdr);/* Functions for dumping PTLRPC fields */ void dump_rniobuf (struct niobuf_remote *rnb);
drivers/staging/lustre/lustre/llite/file.c +106 -0
118 lines not on this page · raw message
drivers/staging/lustre/lustre/llite/vvp_io.c +3 -0
@@ -1302,6 +1302,9 @@ static int vvp_io_read_ahead(const struct lu_env *env, }, [CIT_MISC ] = { .cio_fini = vvp_io_fini + }, + [CIT_LADVISE ] = { + .cio_fini = vvp_io_fini } }, .cio_read_ahead = vvp_io_read_ahead,
drivers/staging/lustre/lustre/lov/lov_io.c +28 -0
@@ -123,6 +123,14 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, }break ; } +case CIT_LADVISE : { + io->u.ci_ladvise.li_start = start; + io->u.ci_ladvise.li_end = end; + io->u.ci_ladvise.li_fid = parent->u.ci_ladvise.li_fid; + io->u.ci_ladvise.li_advice = parent->u.ci_ladvise.li_advice; + io->u.ci_ladvise.li_flags = parent->u.ci_ladvise.li_flags; +break ; + }default :break ; }
@@ -315,6 +323,12 @@ static int lov_io_slice_init(struct lov_io *lio, struct lov_object *obj,break ; } +case CIT_LADVISE : { + lio->lis_pos = io->u.ci_ladvise.li_start; + lio->lis_endpos = io->u.ci_ladvise.li_end; +break ; + } +case CIT_MISC : lio->lis_pos =0 ; lio->lis_endpos =OBD_OBJECT_EOF ;
@@ -837,6 +851,15 @@ static void lov_io_fsync_end(const struct lu_env *env, .cio_start = lov_io_start, .cio_end = lov_io_fsync_end }, + [CIT_LADVISE] = { + .cio_fini = lov_io_fini, + .cio_iter_init = lov_io_iter_init, + .cio_iter_fini = lov_io_iter_fini, + .cio_lock = lov_io_lock, + .cio_unlock = lov_io_unlock, + .cio_start = lov_io_start, + .cio_end = lov_io_end + }, [CIT_MISC] = { .cio_fini = lov_io_fini }
@@ -908,6 +931,9 @@ static void lov_empty_impossible(const struct lu_env *env, [CIT_FSYNC ] = { .cio_fini = lov_empty_io_fini }, + [CIT_LADVISE ] = { + .cio_fini = lov_empty_io_fini + }, [CIT_MISC ] = { .cio_fini = lov_empty_io_fini }
@@ -950,6 +976,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, result =0 ;break ;case CIT_FSYNC : +case CIT_LADVISE :case CIT_SETATTR :case CIT_DATA_VERSION : result =1 ;
@@ -989,6 +1016,7 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,break ;case CIT_MISC :case CIT_FSYNC : +case CIT_LADVISE :case CIT_DATA_VERSION : result =1 ;break ;
drivers/staging/lustre/lustre/obdclass/cl_io.c +2 -0
@@ -140,6 +140,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io)LASSERT (ergo (io->ci_ignore_layout || !io->ci_verify_layout, !io->ci_need_restart));break ; +case CIT_LADVISE : +break ;default :LBUG (); }
drivers/staging/lustre/lustre/osc/osc_cl_internal.h +1 -0
@@ -110,6 +110,7 @@ struct osc_thread_info {pgoff_t oti_fn_index;/* first non-overlapped index */ struct cl_sync_io oti_anchor;struct cl_req_attr oti_req_attr; +struct lu_buf oti_ladvise_buf; };struct osc_object {
drivers/staging/lustre/lustre/osc/osc_dev.c +1 -0
@@ -122,6 +122,7 @@ static void osc_key_fini(const struct lu_context *ctx, {struct osc_thread_info *info = data; +kvfree (info->oti_ladvise_buf.lb_buf);kmem_cache_free (osc_thread_kmem, info); }
drivers/staging/lustre/lustre/osc/osc_internal.h +4 -0
@@ -129,6 +129,10 @@ int osc_sync_base(struct osc_object *exp, struct obdo *oa, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset); +int osc_ladvise_base (struct obd_export *exp,struct obdo *oa, +struct ladvise_hdr *ladvise_hdr, +obd_enqueue_update_f upcall,void *cookie, +struct ptlrpc_request_set *rqset);int osc_process_config_base (struct obd_device *obd,struct lustre_cfg *cfg);int osc_build_rpc (const struct lu_env *env,struct client_obd *cli,struct list_head *ext_list,int cmd);
drivers/staging/lustre/lustre/osc/osc_io.c +79 -0
91 lines not on this page · raw message
drivers/staging/lustre/lustre/osc/osc_request.c +94 -0
106 lines not on this page · raw message
drivers/staging/lustre/lustre/ptlrpc/layout.c +24 -0
@@ -605,6 +605,13 @@ &RMF_FIEMAP_VAL }; +static const struct req_msg_field *ost_ladvise[] = { + &RMF_PTLRPC_BODY , + &RMF_OST_BODY , + &RMF_OST_LADVISE_HDR , + &RMF_OST_LADVISE , +}; +static const struct req_msg_field *ost_get_fiemap_server[] = { &RMF_PTLRPC_BODY , &RMF_FIEMAP_VAL
@@ -716,6 +723,7 @@ &RQF_OST_GET_INFO_LAST_FID , &RQF_OST_SET_INFO_LAST_FID , &RQF_OST_GET_INFO_FIEMAP , + &RQF_OST_LADVISE , &RQF_LDLM_ENQUEUE , &RQF_LDLM_ENQUEUE_LVB , &RQF_LDLM_CONVERT,
@@ -1110,6 +1118,18 @@ struct req_msg_field RMF_SWAP_LAYOUTS =DEFINE_MSGF ("swap_layouts" ,0 ,sizeof (struct mdc_swap_layouts ), lustre_swab_swap_layouts,NULL );EXPORT_SYMBOL (RMF_SWAP_LAYOUTS ); + +struct req_msg_field RMF_OST_LADVISE_HDR = +DEFINE_MSGF ("ladvise_request" ,0 ,sizeof (struct ladvise_hdr ), + lustre_swab_ladvise_hdr,NULL ); +EXPORT_SYMBOL (RMF_OST_LADVISE_HDR ); + +struct req_msg_field RMF_OST_LADVISE = +DEFINE_MSGF ("ladvise_request" ,RMF_F_STRUCT_ARRAY , +sizeof (struct lu_ladvise ), + lustre_swab_ladvise,NULL ); +EXPORT_SYMBOL (RMF_OST_LADVISE ); +/* * Request formats. */
@@ -1552,6 +1572,10 @@ struct req_format RQF_OST_GET_INFO_FIEMAP = ost_get_fiemap_server);EXPORT_SYMBOL (RQF_OST_GET_INFO_FIEMAP ); +struct req_format RQF_OST_LADVISE = +DEFINE_REQ_FMT0 ("OST_LADVISE" , ost_ladvise, ost_body_only); +EXPORT_SYMBOL (RQF_OST_LADVISE ); +/* Convenience macro */ #define FMT_FIELD (fmt, i, j) ((fmt)->rf_fields[(i)].d[(j)])
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -0
@@ -66,6 +66,7 @@ { OST_QUOTACHECK, "ost_quotacheck" }, { OST_QUOTACTL, "ost_quotactl" }, { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" }, + { OST_LADVISE, "ost_ladvise" }, { MDS_GETATTR, "mds_getattr" }, { MDS_GETATTR_NAME, "mds_getattr_lock" }, { MDS_CLOSE, "mds_close" },
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +19 -0
@@ -2309,3 +2309,22 @@ void lustre_swab_close_data(struct close_data *cd)lustre_swab_lu_fid (&cd->cd_fid);__swab64s (&cd->cd_data_version); } + +void lustre_swab_ladvise (struct lu_ladvise *ladvise) +{ +swab64s (&ladvise->lla_start); +swab64s (&ladvise->lla_end); +swab64s (&ladvise->lla_advice); + BUILD_BUG_ON(!offsetof(typeof(*ladvise), lla_padding)); +} +EXPORT_SYMBOL (lustre_swab_ladvise); + +void lustre_swab_ladvise_hdr (struct ladvise_hdr *ladvise_hdr) +{ +swab32s (&ladvise_hdr->lah_magic); +swab32s (&ladvise_hdr->lah_count); +swab64s (&ladvise_hdr->lah_flags); + BUILD_BUG_ON(!offsetof(typeof(*ladvise_hdr), lah_padding1)); + BUILD_BUG_ON(!offsetof(typeof(*ladvise_hdr), lah_padding2)); +} +EXPORT_SYMBOL (lustre_swab_ladvise_hdr);
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +53 -1
64 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/18 lustre: ladvise: Add feature of giving file access advices
Quoted 24 lines · James Simmons
From: Li Xi <[email protected]>
The
fadvise()system call provided by Linux kernel enables applications to give advices or hints about how a file will be accessed. However, It is only a client side mechanism which is not enough for distributed file systems like Lustre, because in order to tune system-wide cache or read-ahead policies, servers need to understand the advices too.This patch adds a new feature named ladvise which provides new APIs and utils to give advices about the access pattern of Lustre files with the purpose of performance improvement. It is similar to Linux
fadvise()system call, except it forwards the advices directly from Lustre client to server. The server side codes will apply appropriate read-ahead and caching techniques for the corresponding files.A typical workload for ladvise is e.g. a bunch of different clients are doing small random reads of a file, so prefetching pages into OSS cache with big linear reads before the random IO is a net benefit. Fetching all that data into each client cache with
fadvise()may not be, due to much more data being sent to the client.
...
drivers/staging/lustre/lustre/llite/file.c static inline long ll_lease_type_from_fmode(fmode_t fmode) · line 2306
Quoted 8 lines
drivers/staging/lustre/lustre/llite/file.c +8
-0+case LL_IOC_LADVISE : { +struct ladvise_hdr *ladvise_hdr; +int alloc_size =sizeof (*ladvise_hdr); +int num_advise; +int i; + + rc =0 ; + ladvise_hdr =kzalloc (alloc_size,GFP_NOFS );
Lustre really needs to get more sensible about when to use GFP_NOFS and when to use GFP_KERNEL.
NOFS is only needed when the allocation cannot wait while reclaim enters the filesystem, due to possible deadlock. So if you are holding a lock or some other resource that writeout might need, use NOFS. In this case, there is no possible conflict with writeout, so GFP_KERNEL should be used.
In this case, alloc_size is 32, so I wonder why it is allocating memory at all rather than just using the stack.
Below the memory is freed and allocated again (why not realloc?) so an allocation is justified there. That should be GFP_KERNEL as well.
Later in osc_io_ladvise_start() there is a kvzalloc() with GFP_NOFS. I suspect that should be GFP_KERNEL as well, especially as vmalloc doesn't properly support GFP_NOFS and never has.
Again, I'll probably apply this anyway...
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/1f610b00/attachment.sig>
PATCH 2/18 lustre: ladvise: Add feature of giving file access advices
Quoted 21 lines
drivers/staging/lustre/lustre/llite/file.c static inline long ll_lease_type_from_fmode(fmode_t fmode) · line 2306
Quoted 9 lines
drivers/staging/lustre/lustre/llite/file.c +8
-0+case LL_IOC_LADVISE : { +struct ladvise_hdr *ladvise_hdr; +int alloc_size =sizeof (*ladvise_hdr); +int num_advise; +int i; + + rc =0 ; + ladvise_hdr =kzalloc (alloc_size,GFP_NOFS );Lustre really needs to get more sensible about when to use
GFP_NOFSand when to useGFP_KERNEL.
NOFS is only needed when the allocation cannot wait while reclaim enters the filesystem, due to possible deadlock. So if you are holding a lock or some other resource that writeout might need, use NOFS. In this case, there is no possible conflict with writeout, soGFP_KERNELshould be used.In this case,
alloc_sizeis 32, so I wonder why it is allocating memory at all rather than just using the stack.
Quoted 6 lines
Below the memory is freed and allocated again (why not realloc?) so an allocation is justified there. That should be
GFP_KERNELas well.Later in
osc_io_ladvise_start()there is akvzalloc()withGFP_NOFS. I suspect that should beGFP_KERNELas well, especially as vmalloc doesn't properly supportGFP_NOFSand never has.
This is the result of the porting from the OpenSFS tree. So in the OpenSFS branch it still does all memory allocations using its OBD_ALLOC* wrappers. Unfolding those wrappers you will see its mostly kmallocs done with the GFP_NOFS flag. This is the same reason lustre avoids using the kasprintf() and related functions as well. Those wrappers were developed to be used to locate memory leaks which was done long before KASAN and trace events was created. Looking at __OBD_VMALLOC_VERBOSE() you will see its using GFP_NOFS which appears to not to be even supported. Oh fun!!!
Since we are on this topic it might be good idea to discuss getting onto 0day and work to get KASAN going with the linux lustre client branch. The directions are not very clear on how to set it up. Have you ever worked with zero day? As for KASAN that can be done locally but sadly you need at least gcc 4.9.2 which in my setup I don't have. I did notice a lustre instance exist on 0day but it doesn't look alive in any way.
As a side note I did apply for lustre-devel to be include on patchworks.linux.org. They are currently in the process to upgrade to a newer software stack so it will another week or so for it to be visible.
PATCH 3/18 lustre: fileset: add fileset mount support
In reply to James SimmonsFrom: Lai Siyao <[email protected]>
This patch enables client to mount subdirectory as fileset.
usage: mount -t lustre mgsname:/fsname/subdir /mount/point
* mdt lookup fileset fid and return to client during mount.
* fid2path support for fileset.
WC-bug-id: https://jira.whamcloud.com/browse/LU-28
Reviewed-on: http://review.whamcloud.com/5007
--- .../lustre/include/uapi/linux/lustre/lustre_idl.h | 7 ++- .../staging/lustre/lustre/include/lustre_disk.h | 2 + .../lustre/lustre/include/lustre_req_layout.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 3 +- drivers/staging/lustre/lustre/include/obd_class.h | 5 ++- .../staging/lustre/lustre/include/obd_support.h | 4 +- drivers/staging/lustre/lustre/llite/file.c | 18 ++++++++ drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 30 +++++++------ drivers/staging/lustre/lustre/mdc/mdc_request.c | 50 ++++++++++++++++++---- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 23 +++++++++- drivers/staging/lustre/lustre/ptlrpc/layout.c | 14 ++++-- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 12 +++--- 14 files changed, 135 insertions(+), 43 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +5 -2
@@ -1244,7 +1244,7 @@ enum mds_cmd {MDS_READPAGE =37 ,MDS_CONNECT =38 ,MDS_DISCONNECT =39 , -MDS_GETSTATUS =40 , +MDS_GET_ROOT =40 ,MDS_STATFS =41 ,MDS_PIN =42 ,/* obsolete, never used in a release */ MDS_UNPIN = 43, /* obsolete, never used in a release */
@@ -2626,7 +2626,10 @@ struct getinfo_fid2path {__u64 gf_recno;__u32 gf_linkno;__u32 gf_pathlen; -char gf_path[0 ]; +union { +char gf_path[0 ]; +struct lu_fid gf_root_fid[0 ]; + } gf_u; } __packed;/** path2parent request/reply structures */
drivers/staging/lustre/lustre/include/lustre_disk.h +2 -0
@@ -78,6 +78,7 @@ struct lustre_mount_data {int lmd_recovery_time_hard;char *lmd_dev;/* device name */ char *lmd_profile;/* client only */ +char *lmd_fileset;/* mount fileset */ char *lmd_mgssec;/* sptlrpc flavor to mgs */ char *lmd_opts;/* lustre mount options (as opposed to * _device_ mount options)
@@ -134,6 +135,7 @@ struct lustre_sb_info {#define s2lsi_nocast (sb) ((sb)->s_fs_info)#define get_profile_name (sb) (s2lsi(sb)->lsi_lmd->lmd_profile) +#define get_mount_fileset (sb) (s2lsi(sb)->lsi_lmd->lmd_fileset)/****************** prototypes *********************/
drivers/staging/lustre/lustre/include/lustre_req_layout.h +1 -1
@@ -133,7 +133,7 @@ void req_capsule_shrink(struct req_capsule *pill,extern struct req_format RQF_MDS_CONNECT ;extern struct req_format RQF_MDS_DISCONNECT ;extern struct req_format RQF_MDS_STATFS ; -extern struct req_format RQF_MDS_GETSTATUS ; +extern struct req_format RQF_MDS_GET_ROOT ;extern struct req_format RQF_MDS_SYNC ;extern struct req_format RQF_MDS_GETXATTR ;extern struct req_format RQF_MDS_GETATTR ;
drivers/staging/lustre/lustre/include/obd.h +2 -1
@@ -920,7 +920,8 @@ struct obd_client_handle {struct cl_attr ;struct md_ops { -int (*getstatus)(struct obd_export *,struct lu_fid *); +int (*getstatus)(struct obd_export *exp,const char *fileset, +struct lu_fid *fid);int (*null_inode)(struct obd_export *,const struct lu_fid *);int (*close)(struct obd_export *,struct md_op_data *,struct md_open_data *,struct ptlrpc_request **);
drivers/staging/lustre/lustre/include/obd_class.h +3 -2
@@ -1180,13 +1180,14 @@ static inline int obd_register_observer(struct obd_device *obd, }/* metadata helpers */ -static inline int md_getstatus (struct obd_export *exp,struct lu_fid *fid) +static inline int md_get_root (struct obd_export *exp,const char *fileset, +struct lu_fid *fid) {int rc;EXP_CHECK_MD_OP (exp, getstatus);EXP_MD_COUNTER_INCREMENT (exp, getstatus); - rc =MDP (exp->exp_obd, getstatus)(exp, fid); + rc =MDP (exp->exp_obd, getstatus)(exp, fileset, fid);return rc; }
drivers/staging/lustre/lustre/include/obd_support.h +2 -2
@@ -135,8 +135,8 @@#define OBD_FAIL_MDS_CONNECT_PACK 0x118#define OBD_FAIL_MDS_REINT_NET_REP 0x119#define OBD_FAIL_MDS_DISCONNECT_NET 0x11a -#define OBD_FAIL_MDS_GETSTATUS_NET 0x11b -#define OBD_FAIL_MDS_GETSTATUS_PACK 0x11c +#define OBD_FAIL_MDS_GET_ROOT_NET 0x11b +#define OBD_FAIL_MDS_GET_ROOT_PACK 0x11c#define OBD_FAIL_MDS_STATFS_PACK 0x11d#define OBD_FAIL_MDS_STATFS_NET 0x11e#define OBD_FAIL_MDS_GETATTR_NAME_NET 0x11f
drivers/staging/lustre/lustre/llite/file.c +18 -0
@@ -1594,6 +1594,13 @@ int ll_fid2path(struct inode *inode, void __user *arg) goto gf_free; } +/* +* append root FID after gfout to let MDT know the root FID so that it +* can lookup the correct path, this is mainly for fileset. +* old server without fileset mount support will ignore this. +*/ + *gfout->gf_u.gf_root_fid = *ll_inode2fid (inode); +/* Call mdc_iocontrol */ rc =obd_iocontrol (OBD_IOC_FID2PATH , exp, outsize, gfout,NULL );if (rc !=0 )
@@ -2725,6 +2732,16 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, goto out_free; } +/* +* lfs migrate command needs to be blocked on the client +* by checking the migrate FID against the FID of the +* filesystem root. +*/ +if (child_inode == parent->i_sb->s_root->d_inode) { + rc = -EINVAL ; + goto out_iput; + } +inode_lock (child_inode); op_data->op_fid3 = *ll_inode2fid (child_inode);if (!fid_is_sane (&op_data->op_fid3)) {
@@ -2807,6 +2824,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,clear_nlink (child_inode); out_unlock:inode_unlock (child_inode); +out_iput:iput (child_inode); out_free:ll_finish_md_op_data (op_data);
drivers/staging/lustre/lustre/llite/llite_lib.c +4 -2
@@ -201,7 +201,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)OBD_CONNECT_DISP_STRIPE |OBD_CONNECT_LFSCK |OBD_CONNECT_OPEN_BY_FID |OBD_CONNECT_DIR_STRIPE | -OBD_CONNECT_BULK_MBITS ; +OBD_CONNECT_BULK_MBITS | +OBD_CONNECT_SUBTREE ;if (sbi->ll_flags &LL_SBI_LRU_RESIZE ) data->ocd_connect_flags |=OBD_CONNECT_LRU_RESIZE ;
@@ -436,7 +437,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)mutex_unlock (&sbi->ll_lco.lco_lock);fid_zero (&sbi->ll_root_fid); - err =md_getstatus (sbi->ll_md_exp, &sbi->ll_root_fid); + err =md_get_root (sbi->ll_md_exp,get_mount_fileset (sb), + &sbi->ll_root_fid);if (err) {CERROR ("cannot mds_connect: rc = %d\n" , err); goto out_lock_cn_cb;
drivers/staging/lustre/lustre/lmv/lmv_obd.c +17 -13
@@ -613,17 +613,20 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, {struct obd_device *obddev =class_exp2obd (exp);struct lmv_obd *lmv = &obddev->u.lmv; -struct getinfo_fid2path *gf; +struct getinfo_fid2path *gf = karg;struct lmv_tgt_desc *tgt;struct getinfo_fid2path *remote_gf =NULL ; +struct lu_fid root_fid;int remote_gf_size =0 ;int rc; - gf = karg; tgt =lmv_find_target (lmv, &gf->gf_fid);if (IS_ERR (tgt))return PTR_ERR (tgt); + root_fid = *gf->gf_u.gf_root_fid; +LASSERT (fid_is_sane (&root_fid)); + repeat_fid2path: rc =obd_iocontrol (OBD_IOC_FID2PATH , tgt->ltd_exp, len, gf, uarg);if (rc !=0 && rc != -EREMOTE )
@@ -637,25 +640,25 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg,char *ptr; ori_gf = karg; -if (strlen (ori_gf->gf_path) +1 + -strlen (gf->gf_path) +1 > ori_gf->gf_pathlen) { +if (strlen (ori_gf->gf_u.gf_path) +1 + +strlen (gf->gf_u.gf_path) +1 > ori_gf->gf_pathlen) { rc = -EOVERFLOW ; goto out_fid2path; } - ptr = ori_gf->gf_path; + ptr = ori_gf->gf_u.gf_path; -memmove (ptr +strlen (gf->gf_path) +1 , ptr, -strlen (ori_gf->gf_path)); +memmove (ptr +strlen (gf->gf_u.gf_path) +1 , ptr, +strlen (ori_gf->gf_u.gf_path)); -strncpy (ptr, gf->gf_path,strlen (gf->gf_path)); - ptr +=strlen (gf->gf_path); +strncpy (ptr, gf->gf_u.gf_path,strlen (gf->gf_u.gf_path)); + ptr +=strlen (gf->gf_u.gf_path); *ptr ='/' ; }CDEBUG (D_INFO ,"%s: get path %s " DFID " rec: %llu ln: %u\n" , tgt->ltd_exp->exp_obd->obd_name, - gf->gf_path,PFID (&gf->gf_fid), gf->gf_recno, + gf->gf_u.gf_path,PFID (&gf->gf_fid), gf->gf_recno, gf->gf_linkno);if (rc ==0 )
@@ -689,7 +692,8 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, remote_gf->gf_fid = gf->gf_fid; remote_gf->gf_recno =-1 ; remote_gf->gf_linkno =-1 ; -memset (remote_gf->gf_path,0 , remote_gf->gf_pathlen); +memset (remote_gf->gf_u.gf_path,0 , remote_gf->gf_pathlen); + *remote_gf->gf_u.gf_root_fid = root_fid; gf = remote_gf; goto repeat_fid2path;
@@ -1387,13 +1391,13 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,return rc; } -static int lmv_getstatus (struct obd_export *exp, +static int lmv_getstatus (struct obd_export *exp,const char *fileset,struct lu_fid *fid) {struct obd_device *obd = exp->exp_obd;struct lmv_obd *lmv = &obd->u.lmv; -return md_getstatus (lmv->tgts[0 ]->ltd_exp, fid); +return md_get_root (lmv->tgts[0 ]->ltd_exp, fileset, fid); } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
drivers/staging/lustre/lustre/mdc/mdc_request.c +42 -8
90 lines not on this page · raw message
drivers/staging/lustre/lustre/obdclass/obd_mount.c +22 -1
@@ -545,6 +545,7 @@ static int lustre_free_lsi(struct super_block *sb)if (lsi->lsi_lmd) {kfree (lsi->lsi_lmd->lmd_dev);kfree (lsi->lsi_lmd->lmd_profile); +kfree (lsi->lsi_lmd->lmd_fileset);kfree (lsi->lsi_lmd->lmd_mgssec);kfree (lsi->lsi_lmd->lmd_opts);if (lsi->lsi_lmd->lmd_exclude_count)
@@ -1073,10 +1074,30 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)/* Remove leading /s from fsname */ while (*++s1 =='/' ) ; + s2 = s1; +while (*s2 !='/' && *s2 !='\0' ) + s2++;/* Freed in lustre_free_lsi */ - lmd->lmd_profile =kasprintf (GFP_NOFS ,"%s-client" , s1); + lmd->lmd_profile =kzalloc (s2 - s1 +8 ,GFP_NOFS );if (!lmd->lmd_profile)return -ENOMEM ; + +strncat (lmd->lmd_profile, s1, s2 - s1); +strncat (lmd->lmd_profile,"-client" ,7 ); + + s1 = s2; + s2 = s1 +strlen (s1) -1 ; +/* Remove padding /s from fileset */ +while (*s2 =='/' ) + s2--; +if (s2 > s1) { + lmd->lmd_fileset =kzalloc (s2 - s1 +2 ,GFP_NOFS ); +if (!lmd->lmd_fileset) { +kfree (lmd->lmd_profile); +return -ENOMEM ; + } +strncat (lmd->lmd_fileset, s1, s2 - s1 +1 ); + } }/* Freed in lustre_free_lsi */
drivers/staging/lustre/lustre/ptlrpc/layout.c +10 -4
@@ -477,6 +477,12 @@ &RMF_EAVALS_LENS }; +static const struct req_msg_field *mds_get_root_client[] = { + &RMF_PTLRPC_BODY , + &RMF_MDT_BODY , + &RMF_NAME +}; +static const struct req_msg_field *mds_getxattr_client[] = { &RMF_PTLRPC_BODY , &RMF_MDT_BODY ,
@@ -674,7 +680,7 @@ &RQF_MDS_CONNECT , &RQF_MDS_DISCONNECT , &RQF_MDS_GET_INFO , - &RQF_MDS_GETSTATUS , + &RQF_MDS_GET_ROOT , &RQF_MDS_STATFS , &RQF_MDS_GETATTR , &RQF_MDS_GETATTR_NAME,
@@ -1228,9 +1234,9 @@ struct req_format RQF_OST_QUOTACTL =DEFINE_REQ_FMT0 ("OST_QUOTACTL" , quotactl_only, quotactl_only);EXPORT_SYMBOL (RQF_OST_QUOTACTL ); -struct req_format RQF_MDS_GETSTATUS = -DEFINE_REQ_FMT0 ("MDS_GETSTATUS" , mdt_body_only, mdt_body_capa); -EXPORT_SYMBOL (RQF_MDS_GETSTATUS ); +struct req_format RQF_MDS_GET_ROOT = +DEFINE_REQ_FMT0 ("MDS_GET_ROOT" , mds_get_root_client, mdt_body_capa); +EXPORT_SYMBOL (RQF_MDS_GET_ROOT );struct req_format RQF_MDS_STATFS =DEFINE_REQ_FMT0 ("MDS_STATFS" , empty, obd_statfs_server);
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -1
@@ -74,7 +74,7 @@ { MDS_READPAGE, "mds_readpage" }, { MDS_CONNECT, "mds_connect" }, { MDS_DISCONNECT, "mds_disconnect" }, - { MDS_GETSTATUS, "mds_getstatus" }, + { MDS_GET_ROOT, "mds_get_root" }, { MDS_STATFS, "mds_statfs" }, { MDS_PIN, "mds_pin" }, { MDS_UNPIN, "mds_unpin" },
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +6 -6
@@ -131,8 +131,8 @@ void lustre_assert_wire_constants(void) (long long)MDS_CONNECT);LASSERTF (MDS_DISCONNECT ==39 ,"found %lld\n" , (long long )MDS_DISCONNECT ); -LASSERTF (MDS_GETSTATUS ==40 ,"found %lld\n" , - (long long )MDS_GETSTATUS ); +LASSERTF (MDS_GET_ROOT ==40 ,"found %lld\n" , + (long long )MDS_GET_ROOT );LASSERTF (MDS_STATFS ==41 ,"found %lld\n" , (long long )MDS_STATFS ); LASSERTF(MDS_PIN == 42, "found %lld\n",
@@ -3708,10 +3708,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct getinfo_fid2path, gf_pathlen));LASSERTF ((int )sizeof (((struct getinfo_fid2path *)0 )->gf_pathlen) ==4 ,"found %lld\n" , (long long )(int )sizeof (((struct getinfo_fid2path *)0 )->gf_pathlen)); - LASSERTF((int)offsetof(struct getinfo_fid2path, gf_path[0]) == 32, "found %lld\n", - (long long)(int)offsetof(struct getinfo_fid2path, gf_path[0])); -LASSERTF ((int )sizeof (((struct getinfo_fid2path *)0 )->gf_path[0 ]) ==1 ,"found %lld\n" , - (long long )(int )sizeof (((struct getinfo_fid2path *)0 )->gf_path[0 ])); + LASSERTF((int)offsetof(struct getinfo_fid2path, gf_u.gf_path[0]) == 32, "found %lld\n", + (long long)(int)offsetof(struct getinfo_fid2path, gf_u.gf_path[0])); +LASSERTF ((int )sizeof (((struct getinfo_fid2path *)0 )->gf_u.gf_path[0 ]) ==1 ,"found %lld\n" , + (long long )(int )sizeof (((struct getinfo_fid2path *)0 )->gf_u.gf_path[0 ]));/* Checks for struct fiemap */ LASSERTF((int)sizeof(struct fiemap) == 32, "found %lld\n",
Signature · 1 line
1.8.3.1
PATCH 3/18 lustre: fileset: add fileset mount support
Quoted 11 lines · James Simmons
From: Lai Siyao <[email protected]>
This patch enables client to mount subdirectory as fileset.
usage: mount -t lustre mgsname:/fsname/subdir /mount/point
* mdt lookup fileset fid and return to client during mount.
*fid2pathsupport for fileset.
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h struct getinfo_fid2path { · line 2632
Quoted 8 lines
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +4
-1@@ -2626,7 +2626,10 @@ struct getinfo_fid2path {__u64 gf_recno;__u32 gf_linkno;__u32 gf_pathlen; -char gf_path[0 ]; +union { +char gf_path[0 ]; +struct lu_fid gf_root_fid[0 ]; + } gf_u;
If you just left the "gf_u" off here, you wouldn't need changes like:
drivers/staging/lustre/lustre/lmv/lmv_obd.c static int lmv_fid2path(struct obd_export *exp, int len, void *karg, · line 649
Quoted 2 lines
drivers/staging/lustre/lustre/lmv/lmv_obd.c +1
-1- ptr = ori_gf->gf_path; + ptr = ori_gf->gf_u.gf_path;
throughout the code.
I'll probably make this change before applying the patch. The rest can come afterwards.
drivers/staging/lustre/lustre/include/lustre_disk.h struct lustre_mount_data { · line 81
Quoted 12 lines
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +0
-0} __packed;/** path2parent request/reply structures */
drivers/staging/lustre/lustre/include/lustre_disk.h +1
-0@@ -78,6 +78,7 @@ struct lustre_mount_data {int lmd_recovery_time_hard;char *lmd_dev;/* device name */ char *lmd_profile;/* client only */ +char *lmd_fileset;/* mount fileset */
Consistent indenting is so over-rated :-)
I really that there is *nothing* you could have done here to make the indenting consistent without including irrelevant changes in the patch, which is generally frowned upon.
This is why it is not unusually to have some clean-up patches first, so that you functional changes can be applied to clean code.
Quoted 4 lines
drivers/staging/lustre/lustre/include/lustre_disk.h +3
-0+if (fileset) +req_capsule_set_size (&req->rq_pill, &RMF_NAME ,RCL_CLIENT , +strlen (fileset) +1 );
drivers/staging/lustre/lustre/include/lustre_disk.h struct lustre_mount_data {
Quoted 10 lines
drivers/staging/lustre/lustre/include/lustre_disk.h +9
-0+ rc =ptlrpc_request_pack (req,LUSTRE_MDS_VERSION ,MDS_GET_ROOT ); +if (rc) { +ptlrpc_request_free (req); +return rc; + }mdc_pack_body (req,NULL ,0 ,0 ,-1 ,0 ); +if (fileset) { +char *name =req_capsule_client_get (&req->rq_pill, &RMF_NAME ); + +memcpy (name, fileset,strlen (fileset));
Why isn't this strcpy()?
I realize that strcpy will add a nul that memcpy doesn't add so if I could see the length being stored, I would understand. But above I see the size passed to req_capsule_set_size() includes the trailing nul.
Am I confused, or is the code confusing?
drivers/staging/lustre/lustre/include/lustre_disk.h static int lmd_parse(char *options, struct lustre_mount_data *lmd) · line 1079
Quoted 7 lines
drivers/staging/lustre/lustre/include/lustre_disk.h +3
-0@@ -1073,10 +1074,30 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)/* Remove leading /s from fsname */ while (*++s1 =='/' ) ; + s2 = s1; +while (*s2 !='/' && *s2 !='\0' ) + s2++;
s2 = strchrnul(s1, '/');
(I only discovered strchrnul() a few days ago).
drivers/staging/lustre/lustre/include/lustre_disk.h static int lmd_parse(char *options, struct lustre_mount_data *lmd) · line 1086
Quoted 8 lines
drivers/staging/lustre/lustre/include/lustre_disk.h +4
-1/* Freed in lustre_free_lsi */ - lmd->lmd_profile =kasprintf (GFP_NOFS ,"%s-client" , s1); + lmd->lmd_profile =kzalloc (s2 - s1 +8 ,GFP_NOFS );if (!lmd->lmd_profile)return -ENOMEM ; + +strncat (lmd->lmd_profile, s1, s2 - s1); +strncat (lmd->lmd_profile,"-client" ,7 );
kasprintf(GFP_KERN, "%.*s-client", s2-s1, s1);
??
drivers/staging/lustre/lustre/include/lustre_disk.h static int lmd_parse(char *options, struct lustre_mount_data *lmd) · line 1099
Quoted 13 lines
drivers/staging/lustre/lustre/include/lustre_disk.h +13
-0+ + s1 = s2; + s2 = s1 +strlen (s1) -1 ; +/* Remove padding /s from fileset */ +while (*s2 =='/' ) + s2--; +if (s2 > s1) { + lmd->lmd_fileset =kzalloc (s2 - s1 +2 ,GFP_NOFS ); +if (!lmd->lmd_fileset) { +kfree (lmd->lmd_profile); +return -ENOMEM ; + } +strncat (lmd->lmd_fileset, s1, s2 - s1 +1 );
This probably deserves to be kasprintf() too.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/bddfa938/attachment.sig>
PATCH 4/18 lustre: obd: rename md_getstatus() to md_get_root()
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
Finish the partial renaming of the the OBD MD method md_getstatus() to md_get_root().
WC-bug-id: https://jira.whamcloud.com/browse/LU-8035
Reviewed-on: http://review.whamcloud.com/19824
--- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/include/obd_class.h | 10 +++++----- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 6 +++--- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +1 -1
@@ -920,7 +920,7 @@ struct obd_client_handle {struct cl_attr ;struct md_ops { -int (*getstatus)(struct obd_export *exp,const char *fileset, +int (*get_root)(struct obd_export *exp,const char *fileset,struct lu_fid *fid);int (*null_inode)(struct obd_export *,const struct lu_fid *); int (*close)(struct obd_export *, struct md_op_data *,
drivers/staging/lustre/lustre/include/obd_class.h +5 -5
@@ -356,8 +356,8 @@ static inline int obd_check_dev_active(struct obd_device *obd)#define MD_COUNTER_OFFSET (op) \ ((offsetof(struct md_ops, op) - \ - offsetof(struct md_ops, getstatus)) \ - / sizeof(((struct md_ops *)(0))->getstatus)) + offsetof(struct md_ops, get_root)) \ + / sizeof(((struct md_ops *)(0))->get_root))#define MD_COUNTER_INCREMENT (obdx, op) \ do { \
@@ -1185,9 +1185,9 @@ static inline int md_get_root(struct obd_export *exp, const char *fileset, {int rc; -EXP_CHECK_MD_OP (exp, getstatus); -EXP_MD_COUNTER_INCREMENT (exp, getstatus); - rc =MDP (exp->exp_obd, getstatus)(exp, fileset, fid); +EXP_CHECK_MD_OP (exp, get_root); +EXP_MD_COUNTER_INCREMENT (exp, get_root); + rc =MDP (exp->exp_obd, get_root)(exp, fileset, fid);return rc; }
drivers/staging/lustre/lustre/lmv/lmv_obd.c +3 -3
@@ -1391,8 +1391,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,return rc; } -static int lmv_getstatus (struct obd_export *exp,const char *fileset, -struct lu_fid *fid) +static int lmv_get_root (struct obd_export *exp,const char *fileset, +struct lu_fid *fid) {struct obd_device *obd = exp->exp_obd;struct lmv_obd *lmv = &obd->u.lmv;
@@ -3076,7 +3076,7 @@ static int lmv_merge_attr(struct obd_export *exp, };static struct md_ops lmv_md_ops = { - .getstatus = lmv_getstatus, + .get_root = lmv_get_root, .null_inode = lmv_null_inode, .close = lmv_close, .create = lmv_create,
drivers/staging/lustre/lustre/mdc/mdc_request.c +1 -1
@@ -2747,7 +2747,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) };static struct md_ops mdc_md_ops = { - .getstatus = mdc_get_root, + .get_root = mdc_get_root, .null_inode = mdc_null_inode, .close = mdc_close, .create = mdc_create,
Signature · 1 line
1.8.3.1
PATCH 5/18 lustre: llite: fast read implementation
In reply to James SimmonsFrom: Jinshan Xiong <[email protected]>
For read operation, if a page is already in cache, it must be covered by a DLM lock. We can take advantage of this by reading cached page without interacting with Lustre. Traditional read will go on if fast read fails.
This patch can improve small read performance significantly. These are the performance data I collected:
+------------+----------------+-----------------+ | | read bs=4k | read bs=1M | +------------+----------------+-----------------+ | w/o patch | 257 MB/s | 1.1 GB/s | +------------+----------------+-----------------+ | w/ patch | 1.2 GB/s | 1.4 GB/s | +------------+----------------+-----------------+
WC-bug-id: https://jira.whamcloud.com/browse/LU-4257
Reviewed-on: http://review.whamcloud.com/20255
--- drivers/staging/lustre/lustre/llite/file.c | 104 +++++++++++++++++++-- .../staging/lustre/lustre/llite/llite_internal.h | 23 ++++- drivers/staging/lustre/lustre/llite/llite_lib.c | 1 + drivers/staging/lustre/lustre/llite/llite_mmap.c | 34 ++++++- drivers/staging/lustre/lustre/llite/lproc_llite.c | 38 ++++++++ drivers/staging/lustre/lustre/llite/rw.c | 68 ++++++++++++-- drivers/staging/lustre/lustre/llite/vvp_internal.h | 1 + 7 files changed, 252 insertions(+), 17 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +98 -6
@@ -953,10 +953,21 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)ll_inode_size_lock (inode); -/* merge timestamps the most recently obtained from mds with -* timestamps obtained from osts +/* +* merge timestamps the most recently obtained from MDS with +* timestamps obtained from OSTSs. +* +* Do not overwrite atime of inode because it may be refreshed +* by file_accessed() function. If the read was served by cache +* data, there is no RPC to be sent so that atime may not be +* transferred to OSTs at all. MDT only updates atime at close time +* if it's at least 'mdd.*.atime_diff' older. +* All in all, the atime in Lustre does not strictly comply with +* POSIX. Solving this problem needs to send an RPC to MDT for each +* read, this will hurt performance. */ - inode->i_atime.tv_sec = lli->lli_atime; +if (inode->i_atime.tv_sec < lli->lli_atime) + inode->i_atime.tv_sec = lli->lli_atime; inode->i_mtime.tv_sec = lli->lli_mtime; inode->i_ctime.tv_sec = lli->lli_ctime;
@@ -1096,7 +1107,7 @@ static void ll_io_init(struct cl_io *io, const struct file *file, int write) range_locked = true; } -ll_cl_add (file, env, io); +ll_cl_add (file, env, io,LCC_RW ); rc =cl_io_loop (env, io);ll_cl_remove (file, env);if (range_locked) {
@@ -1155,23 +1166,104 @@ static void ll_io_init(struct cl_io *io, const struct file *file, int write)return result >0 ? result : rc; } +/** +* The purpose of fast read is to overcome per I/O overhead and improve IOPS +* especially for small I/O. +* +* To serve a read request, CLIO has to create and initialize a cl_io and +* then request DLM lock. This has turned out to have siginificant overhead +* and affects the performance of small I/O dramatically. +* +* It's not necessary to create a cl_io for each I/O. Under the help of read +* ahead, most of the pages being read are already in memory cache and we can +* read those pages directly because if the pages exist, the corresponding DLM +* lock must exist so that page content must be valid. +* +* In fast read implementation, the llite speculatively finds and reads pages +* in memory cache. There are three scenarios for fast read: +* - If the page exists and is uptodate, kernel VM will provide the data and +* CLIO won't be intervened; +* - If the page was brought into memory by read ahead, it will be exported +* and read ahead parameters will be updated; +* - Otherwise the page is not in memory, we can't do fast read. Therefore, +* it will go back and invoke normal read, i.e., a cl_io will be created +* and DLM lock will be requested. +* +* POSIX compliance: posix standard states that read is intended to be atomic. +* Lustre read implementation is in line with Linux kernel read implementation +* and neither of them complies with POSIX standard in this matter. Fast read +* doesn't make the situation worse on single node but it may interleave write +* results from multiple nodes due to short read handling in ll_file_aio_read(). +* +* @env - lu_env +* @iocb - kiocb from kernel +* @iter - user space buffers where the data will be copied +* +* RETURN - number of bytes have been read, or error code if error occurred. +*/ +static ssize_t +ll_do_fast_read (const struct lu_env *env,struct kiocb *iocb, +struct iov_iter *iter) +{ +ssize_t result; + +if (!ll_sbi_has_fast_read (ll_i2sbi (file_inode (iocb->ki_filp)))) +return 0 ; + +/* +* NB: we can't do direct IO for fast read because it will need a lock +* to make IO engine happy. +*/ +if (iocb->ki_filp->f_flags &O_DIRECT ) +return 0 ; + +ll_cl_add (iocb->ki_filp, env,NULL ,LCC_RW ); + result =generic_file_read_iter (iocb, iter); +ll_cl_remove (iocb->ki_filp, env); + +/* +* If the first page is not in cache, generic_file_aio_read() will be +* returned with -ENODATA. +* See corresponding code in ll_readpage(). +*/ +if (result == -ENODATA ) + result =0 ; + +if (result >0 ) +ll_stats_ops_tally (ll_i2sbi (file_inode (iocb->ki_filp)), +LPROC_LL_READ_BYTES , result); + +return result; +} +static ssize_t ll_file_read_iter (struct kiocb *iocb,struct iov_iter *to) {struct lu_env *env;struct vvp_io_args *args;ssize_t result;u16 refcheck; +ssize_t rc2; env =cl_env_get (&refcheck);if (IS_ERR (env))return PTR_ERR (env); + result =ll_do_fast_read (env, iocb, to); +if (result <0 ||iov_iter_count (to) ==0 ) + goto out; + args =ll_env_args (env); args->u.normal.via_iter = to; args->u.normal.via_iocb = iocb; - result =ll_file_io_generic (env, args, iocb->ki_filp,CIT_READ , - &iocb->ki_pos,iov_iter_count (to)); + rc2 =ll_file_io_generic (env, args, iocb->ki_filp,CIT_READ , + &iocb->ki_pos,iov_iter_count (to)); +if (rc2 >0 ) + result += rc2; +else if (result ==0 ) + result = rc2; + +out:cl_env_put (env, &refcheck);return result; }
drivers/staging/lustre/lustre/llite/llite_internal.h +21 -2
@@ -395,6 +395,7 @@ enum stats_track_type {#define LL_SBI_ALWAYS_PING 0x200000/* always ping even if server * suppress_pings */ +#define LL_SBI_FAST_READ 0x400000/* fast read support */ #define LL_SBI_FLAGS { \ "nolck", \
@@ -419,6 +420,7 @@ enum stats_track_type {"xattr_cache" , \"norootsquash" , \"always_ping" , \ + "fast_read", \ }/*
@@ -646,6 +648,11 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi)#endif } +static inline bool ll_sbi_has_fast_read (struct ll_sb_info *sbi) +{ +return !!(sbi->ll_flags &LL_SBI_FAST_READ ); +} +void ll_ras_enter (struct file *f);/* llite/lcommon_misc.c */
@@ -678,6 +685,8 @@ enum {LPROC_LL_OPEN ,LPROC_LL_RELEASE ,LPROC_LL_MAP , +LPROC_LL_FAULT , +LPROC_LL_MKWRITE ,LPROC_LL_LLSEEK ,LPROC_LL_FSYNC , LPROC_LL_READDIR,
@@ -732,9 +741,12 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,int ll_readpage (struct file *file,struct page *page);void ll_readahead_init (struct inode *inode,struct ll_readahead_state *ras);int vvp_io_write_commit (const struct lu_env *env,struct cl_io *io); -struct ll_cl_context *ll_cl_find (struct file *file); -void ll_cl_add (struct file *file,const struct lu_env *env,struct cl_io *io); + +enum lcc_type ; +void ll_cl_add (struct file *file,const struct lu_env *env,struct cl_io *io, +enum lcc_type type);void ll_cl_remove (struct file *file,const struct lu_env *env); +struct ll_cl_context *ll_cl_find (struct file *file);extern const struct address_space_operations ll_aops;
@@ -891,15 +903,22 @@ struct vvp_io_args { } u; }; +enum lcc_type { +LCC_RW =1 , +LCC_MMAP +}; +struct ll_cl_context {struct list_head lcc_list;void *lcc_cookie;const struct lu_env *lcc_env;struct cl_io *lcc_io;struct cl_page *lcc_page; +enum lcc_type lcc_type; };struct ll_thread_info { +struct iov_iter lti_iter;struct vvp_io_args lti_args;struct ra_io_arg lti_ria;struct ll_cl_context lti_io_ctx;
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -0
@@ -122,6 +122,7 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb)atomic_set (&sbi->ll_sa_running,0 );atomic_set (&sbi->ll_agl_total,0 ); sbi->ll_flags |=LL_SBI_AGL_ENABLED ; + sbi->ll_flags |=LL_SBI_FAST_READ ;/* root squash */ sbi->ll_squash.rsi_uid =0 ;
drivers/staging/lustre/lustre/llite/llite_mmap.c +31 -3
@@ -277,6 +277,28 @@ static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)if (IS_ERR (env))return VM_FAULT_ERROR ; +if (ll_sbi_has_fast_read (ll_i2sbi (file_inode (vma->vm_file)))) { +/* do fast fault */ +ll_cl_add (vma->vm_file, env,NULL ,LCC_MMAP ); + fault_ret =filemap_fault (vmf); +ll_cl_remove (vma->vm_file, env); + +/* +* - If there is no error, then the page was found in cache and +* uptodate; +* - If VM_FAULT_RETRY is set, the page existed but failed to +* lock. It will return to kernel and retry; +* - Otherwise, it should try normal fault under DLM lock. +*/ +if ((fault_ret &VM_FAULT_RETRY ) || + !(fault_ret &VM_FAULT_ERROR )) { + result =0 ; + goto out; + } + + fault_ret =0 ; + } + io =ll_fault_io_init (env, vma, vmf->pgoff, &ra_flags);if (IS_ERR (io)) { fault_ret =to_fault_error (PTR_ERR (io));
@@ -293,7 +315,7 @@ static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) vio->u.fault.ft_flags_valid = false;/* May call ll_readpage() */ -ll_cl_add (vma->vm_file, env, io); +ll_cl_add (vma->vm_file, env, io,LCC_MMAP ); result =cl_io_loop (env, io);
@@ -326,6 +348,7 @@ static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)static vm_fault_t ll_fault (struct vm_fault *vmf) { +struct vm_area_struct *vma = vmf->vma;int count =0 ;bool printed = false;vm_fault_t result;
@@ -338,10 +361,12 @@ static vm_fault_t ll_fault(struct vm_fault *vmf)siginitsetinv (&new,sigmask (SIGKILL ) |sigmask (SIGTERM ));sigprocmask (SIG_BLOCK , &new, &old); +ll_stats_ops_tally (ll_i2sbi (file_inode (vma->vm_file)), +LPROC_LL_FAULT ,1 ); + restart: result =ll_fault0 (vmf->vma, vmf); -LASSERT (!(result &VM_FAULT_LOCKED )); -if (result ==0 ) { +if (!(result & (VM_FAULT_RETRY |VM_FAULT_ERROR |VM_FAULT_LOCKED ))) {struct page *vmpage = vmf->page;/* check if this page has been truncated */
@@ -375,6 +400,9 @@ static vm_fault_t ll_page_mkwrite(struct vm_fault *vmf)int err;vm_fault_t ret; +ll_stats_ops_tally (ll_i2sbi (file_inode (vma->vm_file)), +LPROC_LL_MKWRITE ,1 ); +file_update_time (vma->vm_file); do { retry = false;
drivers/staging/lustre/lustre/llite/lproc_llite.c +38 -0
@@ -872,6 +872,41 @@ static ssize_t xattr_cache_store(struct kobject *kobj, }LUSTRE_RW_ATTR (xattr_cache); +static ssize_t fast_read_show (struct kobject *kobj, +struct attribute *attr, +char *buf) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + +return sprintf (buf,"%u\n" , !!(sbi->ll_flags &LL_SBI_FAST_READ )); +} + +static ssize_t fast_read_store (struct kobject *kobj, +struct attribute *attr, +const char *buffer, +size_t count) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); +bool val; +int rc; + + rc =kstrtobool (buffer, &val); +if (rc) +return rc; + +spin_lock (&sbi->ll_lock); +if (val) + sbi->ll_flags |=LL_SBI_FAST_READ ; +else + sbi->ll_flags &= ~LL_SBI_FAST_READ ; +spin_unlock (&sbi->ll_lock); + +return count; +} +LUSTRE_RW_ATTR (fast_read); +static int ll_unstable_stats_seq_show (struct seq_file *m,void *v) {struct super_block *sb = m->private;
@@ -1032,6 +1067,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, &lustre_attr_max_easize.attr, &lustre_attr_default_easize.attr, &lustre_attr_xattr_cache.attr, + &lustre_attr_fast_read.attr, NULL, };
@@ -1068,6 +1104,8 @@ static void llite_sb_release(struct kobject *kobj) { LPROC_LL_OPEN, LPROCFS_TYPE_REGS, "open" }, { LPROC_LL_RELEASE, LPROCFS_TYPE_REGS, "close" }, { LPROC_LL_MAP, LPROCFS_TYPE_REGS, "mmap" }, + { LPROC_LL_FAULT, LPROCFS_TYPE_REGS, "page_fault" }, + { LPROC_LL_MKWRITE, LPROCFS_TYPE_REGS, "page_mkwrite" }, { LPROC_LL_LLSEEK, LPROCFS_TYPE_REGS, "seek" }, { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" }, { LPROC_LL_READDIR, LPROCFS_TYPE_REGS, "readdir" },
drivers/staging/lustre/lustre/llite/rw.c +62 -6
105 lines not on this page · raw message
drivers/staging/lustre/lustre/llite/vvp_internal.h +1 -0
@@ -225,6 +225,7 @@ struct vvp_object {struct vvp_page {struct cl_page_slice vpg_cl;unsigned int vpg_defer_uptodate:1 , + vpg_ra_updated:1 , vpg_ra_used:1 ;/** VM page */ struct page *vpg_page;
Signature · 1 line
1.8.3.1
PATCH 5/18 lustre: llite: fast read implementation
Quoted 10 lines · James Simmons
drivers/staging/lustre/lustre/llite/lproc_llite.c +10
-0+static ssize_t fast_read_store (struct kobject *kobj, +struct attribute *attr, +const char *buffer, +size_t count) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); +bool val; +int rc; +
drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t xattr_cache_store(struct kobject *kobj, · line 904
Quoted 10 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +10
-0+ rc =kstrtobool (buffer, &val); +if (rc) +return rc; + +spin_lock (&sbi->ll_lock); +if (val) + sbi->ll_flags |=LL_SBI_FAST_READ ; +else + sbi->ll_flags &= ~LL_SBI_FAST_READ ; +spin_unlock (&sbi->ll_lock);
This is a little odd... no other code uses ll_lock to protect updates to ll_flags. Various other places (e.g. checksum_pages_store()) updates it unprotected.
Maybe there all need to use ll_lock for protection.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/0137e8ad/attachment-0001.sig>
PATCH 5/18 lustre: llite: fast read implementation
They do. It?s probably gone unnoticed because those updates are mostly directly triggered by users or one time only during initialization, so there?s little risk of colliding.
________________________________
From: lustre-devel <[email protected]> on behalf of NeilBrown <[email protected]>
Sent: Monday, July 2, 2018 11:10:54 PM
To: James Simmons; Andreas Dilger; Oleg Drokin
Cc: Lustre Development List
Subject: Re: [lustre-devel] [PATCH 05/18] lustre: llite: fast read implementation
Quoted 10 lines · James Simmons
drivers/staging/lustre/lustre/llite/lproc_llite.c +10
-0+static ssize_t fast_read_store (struct kobject *kobj, +struct attribute *attr, +const char *buffer, +size_t count) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); +bool val; +int rc; +
drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t xattr_cache_store(struct kobject *kobj, · line 904
Quoted 10 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +10
-0+ rc =kstrtobool (buffer, &val); +if (rc) +return rc; + +spin_lock (&sbi->ll_lock); +if (val) + sbi->ll_flags |=LL_SBI_FAST_READ ; +else + sbi->ll_flags &= ~LL_SBI_FAST_READ ; +spin_unlock (&sbi->ll_lock);
This is a little odd... no other code uses ll_lock to protect updates to ll_flags. Various other places (e.g. checksum_pages_store()) updates it unprotected.
Maybe there all need to use ll_lock for protection.
Thanks,
NeilBrown
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/4a1bdce9/attachment.html>
PATCH 5/18 lustre: llite: fast read implementation
Quoted 1 line · Patrick Farrell
They do. It?s probably gone unnoticed because those updates are mostly directly triggered by users or one time only during initialization, so there?s little risk of colliding.
Agreed. Had there been no locking in this new patch I possibly wouldn't have noticed. But I don't like inconsistencies.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180704/76065dfc/attachment.sig>
PATCH 6/18 lustre: obd: reserve connection flag OBD_CONNECT2_FILE_SECCTX
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
The connection flag OBD_CONNECT2_FILE_SECCTX will be set (in ocd_connect_flags2) if an MDT supports setting the file security context at create time.
WC-bug-id: https://jira.whamcloud.com/browse/LU-5560
Reviewed-on: http://review.whamcloud.com/19970
--- .../lustre/include/uapi/linux/lustre/lustre_idl.h | 4 ++ .../staging/lustre/lustre/include/lustre_import.h | 1 + drivers/staging/lustre/lustre/include/obd_class.h | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 1 + drivers/staging/lustre/lustre/llite/llite_lib.c | 9 +++- .../lustre/lustre/obdclass/lprocfs_status.c | 62 ++++++++++++++++++---- drivers/staging/lustre/lustre/ptlrpc/import.c | 10 ++++ drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 + 8 files changed, 80 insertions(+), 12 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +4 -0
@@ -695,6 +695,10 @@ struct ptlrpc_body_v2 {#define OBD_CONNECT_BULK_MBITS 0x2000000000000000ULL#define OBD_CONNECT_OBDOPACK 0x4000000000000000ULL/* compact OUT obdo */ #define OBD_CONNECT_FLAGS2 0x8000000000000000ULL/* second flags word */ +/* ocd_connect_flags2 flags */ +#define OBD_CONNECT2_FILE_SECCTX 0x1ULL/* set file security +* context at create +*/ /* XXX README XXX: * Please DO NOT add flag values here before first ensuring that this same
drivers/staging/lustre/lustre/include/lustre_import.h +1 -0
@@ -307,6 +307,7 @@ struct obd_import {__u32 imp_connect_op;struct obd_connect_data imp_connect_data;__u64 imp_connect_flags_orig; +u64 imp_connect_flags2_orig;int imp_connect_error;__u32 imp_msg_magic;
drivers/staging/lustre/lustre/include/obd_class.h +2 -1
@@ -80,7 +80,8 @@ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid,int class_notify_sptlrpc_conf (const char *fsname,int namelen); -int obd_connect_flags2str (char *page,int count,__u64 flags,char *sep); +int obd_connect_flags2str (char *page,int count,u64 flags,u64 flags2, +const char *sep);int obd_zombie_impexp_init (void );void obd_zombie_impexp_stop (void );
drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +1 -0
@@ -518,6 +518,7 @@ int client_connect_import(const struct lu_env *env,if (is_mdc) data->ocd_connect_flags |=OBD_CONNECT_MULTIMODRPCS ; imp->imp_connect_flags_orig = data->ocd_connect_flags; + imp->imp_connect_flags2_orig = data->ocd_connect_flags2; } rc =ptlrpc_connect_import (imp);
drivers/staging/lustre/lustre/llite/llite_lib.c +7 -2
@@ -203,7 +203,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)OBD_CONNECT_OPEN_BY_FID |OBD_CONNECT_DIR_STRIPE |OBD_CONNECT_BULK_MBITS | -OBD_CONNECT_SUBTREE ; +OBD_CONNECT_SUBTREE | +OBD_CONNECT_FLAGS2 ; + + data->ocd_connect_flags2 =0 ;if (sbi->ll_flags &LL_SBI_LRU_RESIZE ) data->ocd_connect_flags |=OBD_CONNECT_LRU_RESIZE ;
@@ -292,7 +295,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) goto out_md_fid; }obd_connect_flags2str (buf,PAGE_SIZE , - valid ^CLIENT_CONNECT_MDT_REQD ,"," ); + valid ^CLIENT_CONNECT_MDT_REQD ,0 ,"," );LCONSOLE_ERROR_MSG (0x170 ,"Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n" , sbi->ll_md_exp->exp_obd->obd_name, buf);
@@ -375,6 +378,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)OBD_CONNECT_PINGLESS |OBD_CONNECT_LFSCK |OBD_CONNECT_BULK_MBITS ; + data->ocd_connect_flags2 =0 ; +if (!OBD_FAIL_CHECK (OBD_FAIL_OSC_CONNECT_GRANT_PARAM )) data->ocd_connect_flags |=OBD_CONNECT_GRANT_PARAM ;
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +53 -9
125 lines not on this page · raw message
drivers/staging/lustre/lustre/ptlrpc/import.c +10 -0
@@ -641,6 +641,7 @@ int ptlrpc_connect_import(struct obd_import *imp)* the server is updated on-the-fly we will get the new features. */ imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig; + imp->imp_connect_data.ocd_connect_flags2 = imp->imp_connect_flags2_orig;/* Reset ocd_version each time so the server knows the exact versions */ imp->imp_connect_data.ocd_version =LUSTRE_VERSION_CODE ; imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT ;
@@ -1019,6 +1020,15 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, goto out; } +if ((ocd->ocd_connect_flags2 & imp->imp_connect_flags2_orig) != + ocd->ocd_connect_flags2) { +CERROR ("%s: Server didn't grant requested subset of flags2: asked=%#llx granted=%#llx\n" , + imp->imp_obd->obd_name, imp->imp_connect_flags2_orig, + ocd->ocd_connect_flags2); + rc = -EPROTO ; + goto out; + } + old_connect_flags =exp_connect_flags (exp); exp->exp_connect_data = *ocd; imp->imp_obd->obd_self_export->exp_connect_data = *ocd;
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +2 -0
@@ -1116,6 +1116,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT_OBDOPACK);LASSERTF (OBD_CONNECT_FLAGS2 ==0x8000000000000000ULL ,"found 0x%.16llxULL\n" ,OBD_CONNECT_FLAGS2 ); +LASSERTF (OBD_CONNECT2_FILE_SECCTX ==0x1ULL ,"found 0x%.16llxULL\n" , +OBD_CONNECT2_FILE_SECCTX );LASSERTF (OBD_CKSUM_CRC32 ==0x00000001UL ,"found 0x%.8xUL\n" , (unsigned int )OBD_CKSUM_CRC32 ); LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n",
Signature · 1 line
1.8.3.1
PATCH 6/18 lustre: obd: reserve connection flag OBD_CONNECT2_FILE_SECCTX
Quoted 9 lines · James Simmons
From: "John L. Hammond" <[email protected]>
The connection flag
OBD_CONNECT2_FILE_SECCTXwill be set (inocd_connect_flags2) if an MDT supports setting the file security context at create time.drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-1-static void obd_connect_seq_flags2str (struct seq_file *m,__u64 flags,char *sep)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static int obd_import_flags2str(struct obd_import *imp, struct seq_file *m) · line 689
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4
-2+static void obd_connect_seq_flags2str (struct seq_file *m,u64 flags, +u64 flags2,const char *sep) { -__u64 mask =1 ; +__u64 mask;int i;bool first = true; -for (i =0 ; obd_connect_names[i]; i++, mask <<=1 ) { +for (i =0 , mask =1 ; i <64 ; i++, mask <<=1 ) {
This changes where the loop stops. Previously it stopped when obd_connect_names[i] was NULL. Now it goes on to 64. obd_connect_names[] actually has 66 entries, so this isn't an actual change. However.... (continued below).
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static int obd_import_flags2str(struct obd_import *imp, struct seq_file *m) · line 701
Quoted 13 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4
-1if (flags & mask) {seq_printf (m,"%s%s" , first ? sep :"" , obd_connect_names[i]); first = false; } } -if (flags & ~(mask -1 )) + +if (flags & ~(mask -1 )) {seq_printf (m,"%sunknown flags %#llx" , first ? sep :"" , flags & ~(mask -1 )); + first = false; + }
Now that we know i goes up to 64, this code is pointless. At this point, mask is 0, mask-1 is -1, ~(mask - 1) is zero. So it cannot print anything.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/91b09b52/attachment.sig>
PATCH 7/18 lustre: llite: restore fd_och when putting lease
In reply to James SimmonsFrom: Henri Doreau <[email protected]>
fd_och was not restored when putting back a file lease, preventing from getting a lease, putting it back and taking it again on a FD.
WC-bug-id: https://jira.whamcloud.com/browse/LU-8174
Reviewed-on: http://review.whamcloud.com/20331
--- drivers/staging/lustre/lustre/llite/file.c | 132 +++++++++++++++++++++-------- 1 file changed, 97 insertions(+), 35 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +97 -35
@@ -705,6 +705,97 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock, }/** +* When setting a lease on a file, we take ownership of the lli_mds_*_och +* and save it as fd->fd_och so as to force client to reopen the file even +* if it has an open lock in cache already. +*/ +static int ll_lease_och_acquire (struct inode *inode,struct file *file, +struct lustre_handle *old_handle) +{ +struct ll_file_data *fd =LUSTRE_FPRIVATE (file); +struct ll_inode_info *lli =ll_i2info (inode); +struct obd_client_handle **och_p; +u64 *och_usecount; +int rc =0 ; + +/* Get the openhandle of the file */ +mutex_lock (&lli->lli_och_mutex); +if (fd->fd_lease_och) { + rc = -EBUSY ; + goto out_unlock; + } + +if (!fd->fd_och) { +if (file->f_mode &FMODE_WRITE ) { +LASSERT (lli->lli_mds_write_och); + och_p = &lli->lli_mds_write_och; + och_usecount = &lli->lli_open_fd_write_count; + }else { +LASSERT (lli->lli_mds_read_och); + och_p = &lli->lli_mds_read_och; + och_usecount = &lli->lli_open_fd_read_count; + } + +if (*och_usecount >1 ) { + rc = -EBUSY ; + goto out_unlock; + } + + fd->fd_och = *och_p; + *och_usecount =0 ; + *och_p =NULL ; + } + + *old_handle = fd->fd_och->och_fh; + +out_unlock: +mutex_unlock (&lli->lli_och_mutex); +return rc; +} + +/** +* Release ownership on lli_mds_*_och when putting back a file lease. +*/ +static int ll_lease_och_release (struct inode *inode,struct file *file) +{ +struct ll_file_data *fd =LUSTRE_FPRIVATE (file); +struct ll_inode_info *lli =ll_i2info (inode); +struct obd_client_handle *old_och =NULL ; +struct obd_client_handle **och_p; +u64 *och_usecount; +int rc =0 ; + +mutex_lock (&lli->lli_och_mutex); +if (file->f_mode &FMODE_WRITE ) { + och_p = &lli->lli_mds_write_och; + och_usecount = &lli->lli_open_fd_write_count; + }else { + och_p = &lli->lli_mds_read_och; + och_usecount = &lli->lli_open_fd_read_count; + } + +/* +* The file may have been open by another process (broken lease) so +* *och_p is not NULL. In this case we should simply increase usecount +* and close fd_och. +*/ +if (*och_p) { + old_och = fd->fd_och; + (*och_usecount)++; + }else { + *och_p = fd->fd_och; + *och_usecount =1 ; + } + fd->fd_och =NULL ; +mutex_unlock (&lli->lli_och_mutex); + +if (old_och) + rc =ll_close_inode_openhandle (inode, old_och,0 ,NULL ); + +return rc; +} + +/** * Acquire a lease and open the file. */ static struct obd_client_handle *
@@ -724,45 +815,12 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock,return ERR_PTR (-EINVAL );if (file) { -struct ll_inode_info *lli =ll_i2info (inode); -struct ll_file_data *fd =LUSTRE_FPRIVATE (file); -struct obd_client_handle **och_p; -__u64 *och_usecount; -if (!(fmode & file->f_mode) || (file->f_mode &FMODE_EXEC ))return ERR_PTR (-EPERM ); -/* Get the openhandle of the file */ - rc = -EBUSY ; -mutex_lock (&lli->lli_och_mutex); -if (fd->fd_lease_och) { -mutex_unlock (&lli->lli_och_mutex); -return ERR_PTR (rc); - } - -if (!fd->fd_och) { -if (file->f_mode &FMODE_WRITE ) { -LASSERT (lli->lli_mds_write_och); - och_p = &lli->lli_mds_write_och; - och_usecount = &lli->lli_open_fd_write_count; - }else { -LASSERT (lli->lli_mds_read_och); - och_p = &lli->lli_mds_read_och; - och_usecount = &lli->lli_open_fd_read_count; - } -if (*och_usecount ==1 ) { - fd->fd_och = *och_p; - *och_p =NULL ; - *och_usecount =0 ; - rc =0 ; - } - } -mutex_unlock (&lli->lli_och_mutex); -if (rc <0 )/* more than 1 opener */ + rc =ll_lease_och_acquire (inode, file, &old_handle); +if (rc)return ERR_PTR (rc); - -LASSERT (fd->fd_och); - old_handle = fd->fd_och->och_fh; } och =kzalloc (sizeof (*och),GFP_NOFS );
@@ -2333,6 +2391,10 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,if (rc <0 )return rc; + rc =ll_lease_och_release (inode, file); +if (rc <0 ) +return rc; +if (lease_broken) fmode =0 ;
Signature · 1 line
1.8.3.1
PATCH 8/18 lustre: security: send file security context for creates
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
Send file security context to MDT along with create RPCs. This closes the insecure window between creation and setting of the security context that existed previously. It also avoids a potential LDLM hang which arises from ll_create_it() when we send a MDS_SETXATTR RPC while holding the lookup+layout lock returned from open.
WC-bug-id: https://jira.whamcloud.com/browse/LU-5560
Reviewed-on: http://review.whamcloud.com/19971
--- .../lustre/lustre/include/lustre_req_layout.h | 4 +- drivers/staging/lustre/lustre/include/obd.h | 5 ++ drivers/staging/lustre/lustre/llite/dir.c | 54 ++++++++++++++++------ .../staging/lustre/lustre/llite/llite_internal.h | 11 ++++- drivers/staging/lustre/lustre/llite/llite_lib.c | 14 ++++++ drivers/staging/lustre/lustre/llite/namei.c | 40 ++++++++++++++-- .../staging/lustre/lustre/llite/xattr_security.c | 38 ++++++++++++++- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 ++ drivers/staging/lustre/lustre/mdc/mdc_lib.c | 32 +++++++++++++ drivers/staging/lustre/lustre/mdc/mdc_locks.c | 7 +++ drivers/staging/lustre/lustre/mdc/mdc_reint.c | 7 +++ drivers/staging/lustre/lustre/ptlrpc/layout.c | 28 +++++++++-- 12 files changed, 218 insertions(+), 26 deletions(-)
drivers/staging/lustre/lustre/include/lustre_req_layout.h +3 -1
@@ -60,7 +60,7 @@ enum req_location { };/* Maximal number of fields (buffers) in a request message. */ -#define REQ_MAX_FIELD_NR 9 +#define REQ_MAX_FIELD_NR 10struct req_capsule {struct ptlrpc_request *rc_req;
@@ -236,6 +236,8 @@ void req_capsule_shrink(struct req_capsule *pill,extern struct req_msg_field RMF_GETINFO_VALLEN ;extern struct req_msg_field RMF_GETINFO_KEY ;extern struct req_msg_field RMF_CLOSE_DATA ; +extern struct req_msg_field RMF_FILE_SECCTX_NAME ; +extern struct req_msg_field RMF_FILE_SECCTX ;/* * connection handle received in MDS_CONNECT request.
drivers/staging/lustre/lustre/include/obd.h +5 -0
@@ -755,6 +755,11 @@ struct md_op_data {__u64 op_data_version;struct lustre_handle op_lease_handle; +/* File security context, for creates. */ +const char *op_file_secctx_name; +void *op_file_secctx; +u32 op_file_secctx_size; +/* default stripe offset */ __u32 op_default_stripe_offset; };
drivers/staging/lustre/lustre/llite/dir.c +41 -13
104 lines not on this page · raw message
drivers/staging/lustre/lustre/llite/llite_internal.h +9 -2
@@ -261,8 +261,11 @@ static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)int ll_xattr_cache_get (struct inode *inode,const char *name,char *buffer,size_t size,__u64 valid); -int ll_init_security (struct dentry *dentry,struct inode *inode, -struct inode *dir); +int ll_dentry_init_security (struct dentry *dentry,int mode,struct qstr *name, +const char **secctx_name,void **secctx, +u32 *secctx_size); +int ll_inode_init_security (struct dentry *dentry,struct inode *inode, +struct inode *dir);/* * Locking to guarantee consistency of non-atomic updates to long long i_size,
@@ -396,6 +399,9 @@ enum stats_track_type {* suppress_pings */ #define LL_SBI_FAST_READ 0x400000/* fast read support */ +#define LL_SBI_FILE_SECCTX 0x800000/* set file security context at +* create +*/ #define LL_SBI_FLAGS { \ "nolck", \
@@ -421,6 +427,7 @@ enum stats_track_type {"norootsquash" , \"always_ping" , \"fast_read" , \ + "file_secctx", \ }/*
drivers/staging/lustre/lustre/llite/llite_lib.c +14 -0
@@ -42,6 +42,7 @@#include <linux/types.h> #include <linux/mm.h> #include <linux/random.h> +#include <linux/security.h> #include <linux/fs_struct.h> #include <uapi/linux/lustre/lustre_ioctl.h>
@@ -149,6 +150,12 @@ static void ll_free_sbi(struct super_block *sb)kfree (sbi); } +static inline int obd_connect_has_secctx (struct obd_connect_data *data) +{ +return data->ocd_connect_flags &OBD_CONNECT_FLAGS2 && + data->ocd_connect_flags2 &OBD_CONNECT2_FILE_SECCTX ; +} +static int client_common_fill_super (struct super_block *sb,char *md,char *dt) {struct inode *root =NULL ;
@@ -240,6 +247,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)if (sbi->ll_flags &LL_SBI_ALWAYS_PING ) data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS ; + data->ocd_connect_flags2 |=OBD_CONNECT2_FILE_SECCTX ; + data->ocd_brw_size =MD_MAX_BRW_SIZE ; err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid,
@@ -347,6 +356,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)if (data->ocd_connect_flags &OBD_CONNECT_LAYOUTLOCK ) sbi->ll_flags |=LL_SBI_LAYOUT_LOCK ; +if (obd_connect_has_secctx (data)) + sbi->ll_flags |=LL_SBI_FILE_SECCTX ; +if (data->ocd_ibits_known &MDS_INODELOCK_XATTR ) {if (!(data->ocd_connect_flags &OBD_CONNECT_MAX_EASIZE )) { LCONSOLE_INFO(
@@ -2370,6 +2382,8 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,void ll_finish_md_op_data (struct md_op_data *op_data) { +security_release_secctx (op_data->op_file_secctx, + op_data->op_file_secctx_size);kfree (op_data); }
drivers/staging/lustre/lustre/llite/namei.c +36 -4
@@ -577,13 +577,28 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, op_data =ll_prep_md_op_data (NULL , parent,NULL , dentry->d_name.name, dentry->d_name.len,0 , opc,NULL ); -if (IS_ERR (op_data)) -return (void *)op_data; +if (IS_ERR (op_data)) { + retval =ERR_CAST (op_data); + goto out; + }/* enforce umask if acl disabled or MDS doesn't support umask */ if (!IS_POSIXACL (parent) || !exp_connect_umask (ll_i2mdexp (parent))) it->it_create_mode &= ~current_umask (); +if (it->it_op &IT_CREAT && +ll_i2sbi (parent)->ll_flags &LL_SBI_FILE_SECCTX ) { + rc =ll_dentry_init_security (dentry, it->it_create_mode, + &dentry->d_name, + &op_data->op_file_secctx_name, + &op_data->op_file_secctx, + &op_data->op_file_secctx_size); +if (rc <0 ) { + retval =ERR_PTR (rc); + goto out; + } + } + rc =md_intent_lock (ll_i2mdexp (parent), op_data, it, &req, &ll_md_blocking_ast,0 );/*
@@ -838,7 +853,10 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry,d_instantiate (dentry, inode); -return ll_init_security (dentry, inode, dir); +if (!(ll_i2sbi (inode)->ll_flags &LL_SBI_FILE_SECCTX )) + rc =ll_inode_init_security (dentry, inode, dir); + +return rc; }void ll_update_times (struct ptlrpc_request *request,struct inode *inode)
@@ -882,11 +900,21 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, goto err_exit; } +if (sbi->ll_flags &LL_SBI_FILE_SECCTX ) { + err =ll_dentry_init_security (dentry, mode, &dentry->d_name, + &op_data->op_file_secctx_name, + &op_data->op_file_secctx, + &op_data->op_file_secctx_size); +if (err <0 ) + goto err_exit; + } + err =md_create (sbi->ll_md_exp, op_data, tgt, tgt_len, mode,from_kuid (&init_user_ns,current_fsuid ()),from_kgid (&init_user_ns,current_fsgid ()),current_cap (), rdev, &request);ll_finish_md_op_data (op_data); + op_data =NULL ;if (err <0 && err != -EREMOTE ) goto err_exit;
@@ -934,11 +962,15 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry,d_instantiate (dentry, inode); - err =ll_init_security (dentry, inode, dir); +if (!(sbi->ll_flags &LL_SBI_FILE_SECCTX )) + err =ll_inode_init_security (dentry, inode, dir); err_exit:if (request)ptlrpc_req_finished (request); +if (!IS_ERR_OR_NULL (op_data)) +ll_finish_md_op_data (op_data); +return err; }
drivers/staging/lustre/lustre/llite/xattr_security.c +37 -1
@@ -36,6 +36,41 @@#include <linux/xattr.h> #include "llite_internal.h" +/* +* Check for LL_SBI_FILE_SECCTX before calling. +*/ +int ll_dentry_init_security (struct dentry *dentry,int mode,struct qstr *name, +const char **secctx_name,void **secctx, +u32 *secctx_size) +{ +int rc; + +/* +* security_dentry_init_security() is strange. Like +* security_inode_init_security() it may return a context (provided a +* Linux security module is enabled) but unlike +* security_inode_init_security() it does not return to us the name of +* the extended attribute to store the context under (for example +* "security.selinux"). So we only call it when we think we know what +* the name of the extended attribute will be. This is OK-ish since +* SELinux is the only module that implements +* security_dentry_init_security(). Note that the NFS client code just +* calls it and assumes that if anything is returned then it must come +* from SELinux. +*/ +if (!selinux_is_enabled ()) +return 0 ; + + rc =security_dentry_init_security (dentry, mode, name, secctx, + secctx_size); +if (rc <0 ) +return rc; + + *secctx_name =XATTR_NAME_SELINUX ; + +return 0 ; +} +/** * A helper function for ll_security_inode_init_security() * that takes care of setting xattrs
@@ -86,7 +121,8 @@* \retval < 0 failure to get security context or set xattr */ int -ll_init_security (struct dentry *dentry,struct inode *inode,struct inode *dir) +ll_inode_init_security (struct dentry *dentry,struct inode *inode, +struct inode *dir) {if (!selinux_is_enabled ())return 0 ;
drivers/staging/lustre/lustre/mdc/mdc_internal.h +4 -0
@@ -54,6 +54,10 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,void mdc_open_pack (struct ptlrpc_request *req,struct md_op_data *op_data,umode_t mode,__u64 rdev,__u64 flags,const void *data,size_t datalen); +void mdc_file_secctx_pack (struct ptlrpc_request *req, +const char *secctx_name, +const void *secctx,size_t secctx_size); +void mdc_unlink_pack (struct ptlrpc_request *req,struct md_op_data *op_data);void mdc_link_pack (struct ptlrpc_request *req,struct md_op_data *op_data); void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
drivers/staging/lustre/lustre/mdc/mdc_lib.c +32 -0
@@ -110,6 +110,30 @@ static void mdc_pack_name(struct ptlrpc_request *req,LASSERT (cpy_len == name_len &&lu_name_is_valid_2 (buf, cpy_len)); } +void mdc_file_secctx_pack (struct ptlrpc_request *req,const char *secctx_name, +const void *secctx,size_t secctx_size) +{ +size_t buf_size; +void *buf; + +if (!secctx_name) +return ; + + buf =req_capsule_client_get (&req->rq_pill, &RMF_FILE_SECCTX_NAME ); + buf_size =req_capsule_get_size (&req->rq_pill, &RMF_FILE_SECCTX_NAME , +RCL_CLIENT ); + +LASSERT (buf_size ==strlen (secctx_name) +1 ); +memcpy (buf, secctx_name, buf_size); + + buf =req_capsule_client_get (&req->rq_pill, &RMF_FILE_SECCTX ); + buf_size =req_capsule_get_size (&req->rq_pill, &RMF_FILE_SECCTX , +RCL_CLIENT ); + +LASSERT (buf_size == secctx_size); +memcpy (buf, secctx, buf_size); +} +void mdc_readdir_pack (struct ptlrpc_request *req,__u64 pgoff,size_t size,const struct lu_fid *fid) {
@@ -159,6 +183,10 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, tmp =req_capsule_client_get (&req->rq_pill, &RMF_EADATA );memcpy (tmp, data, datalen); } + +mdc_file_secctx_pack (req, op_data->op_file_secctx_name, + op_data->op_file_secctx, + op_data->op_file_secctx_size); }static inline __u64 mds_pack_open_flags (__u64 flags)
@@ -224,6 +252,10 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,if (op_data->op_bias &MDS_CREATE_VOLATILE ) cr_flags |=MDS_OPEN_VOLATILE ; + +mdc_file_secctx_pack (req, op_data->op_file_secctx_name, + op_data->op_file_secctx, + op_data->op_file_secctx_size); }if (lmm) {
drivers/staging/lustre/lustre/mdc/mdc_locks.c +7 -0
@@ -288,6 +288,13 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,req_capsule_set_size (&req->rq_pill, &RMF_EADATA ,RCL_CLIENT ,max (lmmsize, obddev->u.cli.cl_default_mds_easize)); +req_capsule_set_size (&req->rq_pill, &RMF_FILE_SECCTX_NAME , +RCL_CLIENT , op_data->op_file_secctx_name ? +strlen (op_data->op_file_secctx_name) +1 :0 ); + +req_capsule_set_size (&req->rq_pill, &RMF_FILE_SECCTX ,RCL_CLIENT , + op_data->op_file_secctx_size); + rc =ldlm_prep_enqueue_req (exp, req, &cancels, count);if (rc <0 ) {ptlrpc_request_free (req);
drivers/staging/lustre/lustre/mdc/mdc_reint.c +7 -0
@@ -190,6 +190,13 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data,req_capsule_set_size (&req->rq_pill, &RMF_EADATA ,RCL_CLIENT , data && datalen ? datalen :0 ); +req_capsule_set_size (&req->rq_pill, &RMF_FILE_SECCTX_NAME , +RCL_CLIENT , op_data->op_file_secctx_name ? +strlen (op_data->op_file_secctx_name) +1 :0 ); + +req_capsule_set_size (&req->rq_pill, &RMF_FILE_SECCTX ,RCL_CLIENT , + op_data->op_file_secctx_size); + rc =mdc_prep_elc_req (exp, req,MDS_REINT , &cancels, count);if (rc) {ptlrpc_request_free (req);
drivers/staging/lustre/lustre/ptlrpc/layout.c +23 -5
@@ -196,7 +196,9 @@ &RMF_CAPA1 , &RMF_NAME , &RMF_EADATA , - &RMF_DLM_REQ + &RMF_DLM_REQ , + &RMF_FILE_SECCTX_NAME , + &RMF_FILE_SECCTX }; static const struct req_msg_field *mds_reint_create_sym_client[] = {
@@ -205,7 +207,9 @@ &RMF_CAPA1 , &RMF_NAME , &RMF_SYMTGT , - &RMF_DLM_REQ + &RMF_DLM_REQ , + &RMF_FILE_SECCTX_NAME , + &RMF_FILE_SECCTX }; static const struct req_msg_field *mds_reint_open_client[] = {
@@ -214,7 +218,9 @@ &RMF_CAPA1 , &RMF_CAPA2 , &RMF_NAME , - &RMF_EADATA + &RMF_EADATA , + &RMF_FILE_SECCTX_NAME , + &RMF_FILE_SECCTX }; static const struct req_msg_field *mds_reint_open_server[] = {
@@ -435,7 +441,9 @@ &RMF_REC_REINT ,/* coincides with mds_reint_create_client[] */ &RMF_CAPA1 , &RMF_NAME , - &RMF_EADATA + &RMF_EADATA , + &RMF_FILE_SECCTX_NAME , + &RMF_FILE_SECCTX }; static const struct req_msg_field *ldlm_intent_open_client[] = {
@@ -446,7 +454,9 @@ &RMF_CAPA1 , &RMF_CAPA2 , &RMF_NAME , - &RMF_EADATA + &RMF_EADATA , + &RMF_FILE_SECCTX_NAME , + &RMF_FILE_SECCTX }; static const struct req_msg_field *ldlm_intent_unlink_client[] = {
@@ -931,6 +941,14 @@ struct req_msg_field RMF_STRING =DEFINE_MSGF ("string" ,RMF_F_STRING ,-1 ,NULL ,NULL );EXPORT_SYMBOL (RMF_STRING ); +struct req_msg_field RMF_FILE_SECCTX_NAME = +DEFINE_MSGF ("file_secctx_name" ,RMF_F_STRING ,-1 ,NULL ,NULL ); +EXPORT_SYMBOL (RMF_FILE_SECCTX_NAME ); + +struct req_msg_field RMF_FILE_SECCTX = +DEFINE_MSGF ("file_secctx" ,0 ,-1 ,NULL ,NULL ); +EXPORT_SYMBOL (RMF_FILE_SECCTX ); +struct req_msg_field RMF_LLOGD_BODY =DEFINE_MSGF ("llogd_body" ,0 ,sizeof (struct llogd_body ), lustre_swab_llogd_body,NULL );
Signature · 1 line
1.8.3.1
PATCH 8/18 lustre: security: send file security context for creates
Quoted 11 lines · James Simmons
From: "John L. Hammond" <[email protected]>
Send file security context to MDT along with create RPCs. This closes the insecure window between creation and setting of the security context that existed previously. It also avoids a potential LDLM hang which arises from
ll_create_it()when we send aMDS_SETXATTRRPC while holding the lookup+layout lock returned from open.
drivers/staging/lustre/lustre/llite/dir.c static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump, · line 484
Quoted 4 lines
drivers/staging/lustre/lustre/llite/dir.c +3
-1-err_exit: +out_inode: +if (inode) +iput (inode);
iput() allows NULL to be passes (as all 'release' function should) so this can be just
iput(inode);
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/8744f815/attachment.sig>
PATCH 9/18 lustre: llite: ladvise protocol changes
In reply to James SimmonsFrom: Patrick Farrell <[email protected]>
This patch makes some changes to the ladvise API and protocol to support lock ahead and possible future users.
Primarily, it separates the userspace API arguments from the structures which go out on the network, and adds a number of 'value' fields without a predefined use.
The meaning of each value field can be different for different advice types, allowing some extensibility.
WC-bug-id: https://jira.whamcloud.com/browse/LU-7225
Reviewed-on: http://review.whamcloud.com/20666
--- .../lustre/include/uapi/linux/lustre/lustre_idl.h | 30 ++++++++++++++++ .../lustre/include/uapi/linux/lustre/lustre_user.h | 37 +++++++++++++------ drivers/staging/lustre/lustre/llite/file.c | 8 ++--- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 12 ++++--- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 42 +++++++++++++++------- 5 files changed, 97 insertions(+), 32 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +30 -0
@@ -2694,5 +2694,35 @@ struct close_data { __u64 cd_reserved[8]; }; +/* +* This is the lu_ladvise struct which goes out on the wire. +* Corresponds to the userspace arg llapi_lu_ladvise. +* value[1-4] are unspecified fields, used differently by different advices +*/ +struct lu_ladvise { +__u16 lla_advice;/* advice type */ +__u16 lla_value1;/* values for different advice types */ +__u32 lla_value2; +__u64 lla_start;/* first byte of extent for advice */ +__u64 lla_end;/* last byte of extent for advice */ +__u32 lla_value3; +__u32 lla_value4; +}; + +/* +* This is the ladvise_hdr which goes on the wire, corresponds to the userspace +* arg llapi_ladvise_hdr. +* value[1-3] are unspecified fields, used differently by different advices +*/ +struct ladvise_hdr { +__u32 lah_magic;/* LADVISE_MAGIC */ +__u32 lah_count;/* number of advices */ +__u64 lah_flags;/* from enum ladvise_flag */ +__u32 lah_value1;/* unused */ +__u32 lah_value2;/* unused */ +__u64 lah_value3;/* unused */ +struct lu_ladvise lah_advise[0 ];/* advices in this header */ +}; +#endif /** @} lustreidl */
drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +26 -11
@@ -276,7 +276,7 @@ struct ost_id {#define LL_IOC_MIGRATE _IOR('f', 247, int)#define LL_IOC_FID2MDTIDX _IOWR('f', 248, struct lu_fid)#define LL_IOC_GETPARENT _IOWR('f', 249, struct getparent) -#define LL_IOC_LADVISE _IOR('f', 250, struct lu_ladvise) +#define LL_IOC_LADVISE _IOR('f', 250, struct llapi_lu_ladvise)/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */ enum ll_lease_type {
@@ -1327,13 +1327,22 @@ enum lu_ladvise_type { LU_LADVISE_INVALID = 0, }; -#define LU_LADVISE_NAMES { } +#define LU_LADVISE_NAMES { \ +} -struct lu_ladvise { -__u64 lla_advice; -__u64 lla_start; -__u64 lla_end; -__u64 lla_padding; +/* +* This is the userspace argument for ladvise. It is currently the same as +* what goes on the wire (struct lu_ladvise), but is defined separately as we +* may need info which is only used locally. +*/ +struct llapi_lu_ladvise { +__u16 lla_advice;/* advice type */ +__u16 lla_value1;/* values for different advice types */ +__u32 lla_value2; +__u64 lla_start;/* first byte of extent for advice */ +__u64 lla_end;/* last byte of extent for advice */ +__u32 lla_value3; +__u32 lla_value4; };enum ladvise_flag {
@@ -1343,13 +1352,19 @@ enum ladvise_flag {#define LADVISE_MAGIC 0x1ADF1CE0#define LF_MASK LF_ASYNC -struct ladvise_hdr { +/* +* This is the userspace argument for ladvise, corresponds to ladvise_hdr which +* is used on the wire. It is defined separately as we may need info which is +* only used locally. +*/ +struct llapi_ladvise_hdr {__u32 lah_magic;/* LADVISE_MAGIC */ __u32 lah_count;/* number of advices */ __u64 lah_flags;/* from enum ladvise_flag */ -__u64 lah_padding1;/* unused */ -__u64 lah_padding2;/* unused */ -struct lu_ladvise lah_advise[0 ]; +__u32 lah_value1;/* unused */ +__u32 lah_value2;/* unused */ +__u64 lah_value3;/* unused */ +struct llapi_lu_ladvise lah_advise[0 ];/* advices in this header */ };#define LAH_COUNT_MAX 1024
drivers/staging/lustre/lustre/llite/file.c +4 -4
@@ -2098,7 +2098,7 @@ static inline long ll_lease_type_from_fmode(fmode_t fmode)* much more data being sent to the client. */ static int ll_ladvise (struct inode *inode,struct file *file,__u64 flags, -struct lu_ladvise *ladvise) +struct llapi_lu_ladvise *ladvise) {struct cl_ladvise_io *lio;struct lu_env *env;
@@ -2458,7 +2458,7 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,return rc; }case LL_IOC_LADVISE : { -struct ladvise_hdr *ladvise_hdr; +struct llapi_ladvise_hdr *ladvise_hdr;int alloc_size =sizeof (*ladvise_hdr);int num_advise;int i;
@@ -2469,7 +2469,7 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,return -ENOMEM ;if (copy_from_user (ladvise_hdr, - (const struct ladvise_hdr __user *)arg, + (const struct llapi_ladvise_hdr __user *)arg, alloc_size)) { rc = -EFAULT ; goto out_ladvise;
@@ -2498,7 +2498,7 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,* TODO: submit multiple advices to one server in a single RPC */ if (copy_from_user (ladvise_hdr, - (const struct ladvise_hdr __user *)arg, + (const struct llapi_advise_hdr __user *)arg, alloc_size)) { rc = -EFAULT ; goto out_ladvise;
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +8 -4
@@ -2312,10 +2312,13 @@ void lustre_swab_close_data(struct close_data *cd)void lustre_swab_ladvise (struct lu_ladvise *ladvise) { +swab16s (&ladvise->lla_advice); +swab16s (&ladvise->lla_value1); +swab32s (&ladvise->lla_value2);swab64s (&ladvise->lla_start);swab64s (&ladvise->lla_end); -swab64s (&ladvise->lla_advice); - BUILD_BUG_ON(!offsetof(typeof(*ladvise), lla_padding)); +swab32s (&ladvise->lla_value3); +swab32s (&ladvise->lla_value4); }EXPORT_SYMBOL (lustre_swab_ladvise);
@@ -2324,7 +2327,8 @@ void lustre_swab_ladvise_hdr(struct ladvise_hdr *ladvise_hdr)swab32s (&ladvise_hdr->lah_magic);swab32s (&ladvise_hdr->lah_count);swab64s (&ladvise_hdr->lah_flags); - BUILD_BUG_ON(!offsetof(typeof(*ladvise_hdr), lah_padding1)); - BUILD_BUG_ON(!offsetof(typeof(*ladvise_hdr), lah_padding2)); +swab32s (&ladvise_hdr->lah_value1); +swab32s (&ladvise_hdr->lah_value2); +swab64s (&ladvise_hdr->lah_value3); }EXPORT_SYMBOL (lustre_swab_ladvise_hdr);
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +29 -13
61 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/18 lustre: ladvise: Add willread advice support for ladvise
In reply to James SimmonsFrom: Li Xi <[email protected]>
This patch adds WILLREAD advice to ladvise framework. OSS will prefetch data into memory when this hint is provided. It is not garanteed how long the cached pages will be kept in memory.
WC-bug-id: https://jira.whamcloud.com/browse/LU-4931
Reviewed-on: http://review.whamcloud.com/12458
--- drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h | 2 ++ drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 4 ++++ 2 files changed, 6 insertions(+)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +2 -0
@@ -1325,9 +1325,11 @@ struct hsm_copy {enum lu_ladvise_type {LU_LADVISE_INVALID =0 , +LU_LADVISE_WILLREAD =1 , };#define LU_LADVISE_NAMES { \ + [LU_LADVISE_WILLREAD] = "willread", \ }/*
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +4 -0
@@ -4243,6 +4243,8 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lu_ladvise, lla_value4));LASSERTF ((int )sizeof (((struct lu_ladvise *)0 )->lla_value4) ==4 ,"found %lld\n" , (long long )(int )sizeof (((struct lu_ladvise *)0 )->lla_value4)); +LASSERTF (LU_LADVISE_WILLREAD ==1 ,"found %lld\n" , + (long long )LU_LADVISE_WILLREAD );/* Checks for struct ladvise_hdr */ LASSERTF(LADVISE_MAGIC == 0x1ADF1CE0, "found 0x%.8x\n",
@@ -4277,4 +4279,6 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ladvise_hdr, lah_advise));LASSERTF ((int )sizeof (((struct ladvise_hdr *)0 )->lah_advise) ==0 ,"found %lld\n" , (long long )(int )sizeof (((struct ladvise_hdr *)0 )->lah_advise)); +LASSERTF (LF_ASYNC ==0x00000001UL ,"found 0x%.8xUL\n" , + (unsigned int )LF_ASYNC ); }
Signature · 1 line
1.8.3.1
PATCH 11/18 lustre: osc: max_pages_per_rpc should be chunk size aligned
In reply to James SimmonsFrom: Bobi Jam <[email protected]>
max_pages_per_rpc should be chunk size aligned.
obd_brw_size need to be at least one block size.
Improve the LASSERT() to an LASSERTF() that prints the related parameters to help debug problem.
WC-bug-id: https://jira.whamcloud.com/browse/LU-8460
Reviewed-on: http://review.whamcloud.com/21825
--- drivers/staging/lustre/lustre/osc/osc_cache.c | 11 ++++++++--- drivers/staging/lustre/lustre/osc/osc_request.c | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/osc/osc_cache.c +8 -3
@@ -681,15 +681,20 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, descr = &olck->ols_cl.cls_lock->cll_descr;LASSERT (descr->cld_mode >=CLM_WRITE ); -LASSERT (cli->cl_chunkbits >=PAGE_SHIFT ); +LASSERTF (cli->cl_chunkbits >=PAGE_SHIFT , +"chunkbits: %u\n" , cli->cl_chunkbits); ppc_bits = cli->cl_chunkbits -PAGE_SHIFT ; chunk_mask = ~((1 << ppc_bits) -1 ); chunksize =1 << cli->cl_chunkbits; chunk = index >> ppc_bits; -/* align end to rpc edge, rpc size may not be a power 2 integer. */ +/* align end to RPC edge */ max_pages = cli->cl_max_pages_per_rpc; -LASSERT ((max_pages & ~chunk_mask) ==0 ); +if ((max_pages & ~chunk_mask) !=0 ) { +CERROR ("max_pages: %#x chunkbits: %u chunk_mask: %#lx\n" , + max_pages, cli->cl_chunkbits, chunk_mask); +return ERR_PTR (-EINVAL ); + } max_end = index - (index % max_pages) + max_pages -1 ; max_end =min_t (pgoff_t, max_end, descr->cld_end);
drivers/staging/lustre/lustre/osc/osc_request.c +5 -0
@@ -931,6 +931,7 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) }if (OCD_HAS_FLAG (ocd,GRANT_PARAM )) { +int chunk_mask;u64 size;/* overhead for each extent insertion */
@@ -938,6 +939,10 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)/* determine the appropriate chunk size used by osc_extent. */ cli->cl_chunkbits =max_t (int,PAGE_SHIFT , ocd->ocd_grant_blkbits); +/* max_pages_per_rpc must be chunk aligned */ + chunk_mask = ~((1 << (cli->cl_chunkbits -PAGE_SHIFT )) -1 ); + cli->cl_max_pages_per_rpc = (cli->cl_max_pages_per_rpc + + ~chunk_mask) & chunk_mask;/* determine maximum extent size, in #pages */ size = (u64 )ocd->ocd_grant_max_blks << ocd->ocd_grant_blkbits; cli->cl_max_extent_pages = size >>PAGE_SHIFT ;
Signature · 1 line
1.8.3.1
PATCH 12/18 lustre: ladvise: Add dontneed advice support for ladvise
In reply to James SimmonsFrom: Li Xi <[email protected]>
This patch addds DONTNEED advice to ladvise framework. OSS will cleanup the page cache of the file when this hint is provided.
WC-bug-id: https://jira.whamcloud.com/browse/LU-4931
Reviewed-on: http://review.whamcloud.com/20203
--- drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h | 2 ++ drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +2 -0
@@ -1326,10 +1326,12 @@ struct hsm_copy {enum lu_ladvise_type {LU_LADVISE_INVALID =0 ,LU_LADVISE_WILLREAD =1 , +LU_LADVISE_DONTNEED =2 , };#define LU_LADVISE_NAMES { \ [LU_LADVISE_WILLREAD] = "willread", \ + [LU_LADVISE_DONTNEED] = "dontneed", \ }/*
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +2 -0
@@ -4245,6 +4245,8 @@ void lustre_assert_wire_constants(void) (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value4));LASSERTF (LU_LADVISE_WILLREAD ==1 ,"found %lld\n" , (long long )LU_LADVISE_WILLREAD ); +LASSERTF (LU_LADVISE_DONTNEED ==2 ,"found %lld\n" , + (long long )LU_LADVISE_DONTNEED );/* Checks for struct ladvise_hdr */ LASSERTF(LADVISE_MAGIC == 0x1ADF1CE0, "found 0x%.8x\n",
Signature · 1 line
1.8.3.1
PATCH 13/18 lustre: ptlrpc: properly set "rq_xid" for 4MB IO
In reply to James SimmonsFrom: Fan Yong <[email protected]>
The commit 8bcaef92664f ("staging: lustre: ptlrpc: mbits is sent within ptlrpc_body") replaced the "rq_xid" with "rq_mbits" as the matchbits of bulk data transferring. To be interoperable with old servers, it introduced the new connection flag:OBD_CONNECT_BULK_MBITS. If the server does not support such feature, then the "rq_xid" would be set the same value as "rq_mbits". Unfortunately, it forgot to handle multiple bulk operations, for example 4MB IO. If the new client wants to make 4MB IO with old server, it may send a small "rq_xid" to the old server, as to the old server will regard it as an 1MB IO or 2MB IO. So the data transfer will not complete because of only part of data transferred. Then the client will timeout failure and retry again and again.
WC-bug-id: https://jira.whamcloud.com/browse/LU-6808
Reviewed-on: http://review.whamcloud.com/22373
--- drivers/staging/lustre/lustre/ptlrpc/client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +7 -2
@@ -3084,8 +3084,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)* 'resend for the -EINPROGRESS resend'. To make it simple, * we opt to generate mbits for all resend cases. */ -if ((bd->bd_import->imp_connect_data.ocd_connect_flags & -OBD_CONNECT_BULK_MBITS )) { +if (OCD_HAS_FLAG (&bd->bd_import->imp_connect_data,BULK_MBITS )) { req->rq_mbits =ptlrpc_next_xid (); }else {/* old version transfers rq_xid to peer as matchbits */
@@ -3115,6 +3114,12 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)* see LU-1431 */ req->rq_mbits +=DIV_ROUND_UP (bd->bd_iov_count,LNET_MAX_IOV ) -1 ; + +/* Set rq_xid as rq_mbits to indicate the final bulk for the old +* server which does not support OBD_CONNECT_BULK_MBITS. LU-6808 +*/ +if (!OCD_HAS_FLAG (&bd->bd_import->imp_connect_data,BULK_MBITS )) + req->rq_xid = req->rq_mbits; }/**
Signature · 1 line
1.8.3.1
PATCH 14/18 lustre: obd: add callback for llog_cat_process_or_fork
In reply to James SimmonsFrom: Alexander Boyko <[email protected]>
Currently llog_process_or_fork() is hard coded to always pass the function pointer llog_cat_process_cb(). Change llog_cat_process_or_fork() to pass in any function pointer which will allow us more options for llog_cat callback routines in the future.
WC-bug-id: https://jira.whamcloud.com/browse/LU-7156
Seagate-bug-id: MRP-2383
Reviewed-on: http://review.whamcloud.com/16416
--- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/obdclass/llog_cat.c +7 -9
@@ -189,7 +189,8 @@ static int llog_cat_process_cb(const struct lu_env *env,static int llog_cat_process_or_fork (const struct lu_env *env,struct llog_handle *cat_llh, -llog_cb_t cb,void *data,int startcat, +llog_cb_t cat_cb,llog_cb_t cb, +void *data,int startcat,int startidx,bool fork) {struct llog_process_data d;
@@ -210,18 +211,15 @@ static int llog_cat_process_or_fork(const struct lu_env *env, cd.lpcd_first_idx = llh->llh_cat_idx; cd.lpcd_last_idx =0 ; - rc =llog_process_or_fork (env, cat_llh, llog_cat_process_cb, - &d, &cd, fork); + rc =llog_process_or_fork (env, cat_llh, cat_cb, &d, &cd, fork);if (rc !=0 )return rc; cd.lpcd_first_idx =0 ; cd.lpcd_last_idx = cat_llh->lgh_last_idx; - rc =llog_process_or_fork (env, cat_llh, llog_cat_process_cb, - &d, &cd, fork); + rc =llog_process_or_fork (env, cat_llh, cat_cb, &d, &cd, fork); }else { - rc =llog_process_or_fork (env, cat_llh, llog_cat_process_cb, - &d,NULL , fork); + rc =llog_process_or_fork (env, cat_llh, cat_cb, &d,NULL , fork); }return rc;
@@ -230,7 +228,7 @@ static int llog_cat_process_or_fork(const struct lu_env *env,int llog_cat_process (const struct lu_env *env,struct llog_handle *cat_llh,llog_cb_t cb,void *data,int startcat,int startidx) { -return llog_cat_process_or_fork (env, cat_llh, cb, data, startcat, - startidx, false); +return llog_cat_process_or_fork (env, cat_llh, llog_cat_process_cb, cb, + data, startcat, startidx, false); }EXPORT_SYMBOL (llog_cat_process);
Signature · 1 line
1.8.3.1
PATCH 15/18 lustre: mount: fix lmd_parse() to handle new delimiters
In reply to James SimmonsFrom: Jian Yu <[email protected]>
The lmd_parse() function parses mount options with comma as delimiter without considering commas in expr_list as follows is a valid LNET nid range syntax:
<expr_list> :== '[' <range_expr> [ ',' <range_expr>] ']'
This patch fixes the above issue by using cfs_parse_nidlist() to parse nid range list instead of using class_parse_nid_quiet() to parse only one nid.
In multi-rail and failover configurations, colon is a valid delimiter in LNET nid list to separate different hosts. This patch fixes lmd_parse()->lmd_parse_nidlist() to handle both comma and colon as delimiters.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/26558
WC-bug-id: https://jira.whamcloud.com/browse/LU-8311
Reviewed-on: http://review.whamcloud.com/21329
WC-bug-id: https://jira.whamcloud.com/browse/LU-5690
Reviewed-on: http://review.whamcloud.com/17036
--- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 112 +++++++++++++++++++-- 1 file changed, 104 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/obdclass/obd_mount.c +104 -8
@@ -889,6 +889,104 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)return 0 ; } +/** +* Find the first delimiter (comma or colon) from the specified \a buf and +* make \a *endh point to the string starting with the delimiter. The commas +* in expression list [...] will be skipped. +* +* @buf a delimiter-separated string +* @endh a pointer to a pointer that will point to the string +* starting with the delimiter +* +* RETURNS true if delimiter is found, false if delimiter is not found +*/ +static bool lmd_find_delimiter (char *buf,char **endh) +{ +char *c = buf; +size_t pos; +bool found; + +if (!buf) +return false; +try_again: +if (*c ==',' || *c ==':' ) +return true; + + pos =strcspn (c,"[:,]" ); +if (!pos) +return false; + +/* Not a valid mount string */ +if (*c ==']' ) { +CWARN ("invalid mount string format\n" ); +return false; + } + + c += pos; +if (*c =='[' ) { + c =strchr (c,']' ); + +/* invalid mount string */ +if (!c) { +CWARN ("invalid mount string format\n" ); +return false; + } + c++; + goto try_again; + } + + found = *c !='\0' ; +if (found && endh) + *endh = c; + +return found; +} + +/** +* Find the first valid string delimited by comma or colon from the specified +* \a buf and parse it to see whether it's a valid nid list. If yes, \a *endh +* will point to the next string starting with the delimiter. +* +* \param[in] buf a delimiter-separated string +* \param[in] endh a pointer to a pointer that will point to the string +* starting with the delimiter +* +* \retval 0 if the string is a valid nid list +* \retval 1 if the string is not a valid nid list +*/ +static int lmd_parse_nidlist (char *buf,char **endh) +{ +struct list_head nidlist; +char *endp = buf; +int rc =0 ; +char tmp; + +if (!buf) +return 1 ; +while (*buf ==',' || *buf ==':' ) + buf++; +if (*buf ==' ' || *buf =='/' || *buf =='\0' ) +return 1 ; + +if (!lmd_find_delimiter (buf, &endp)) + endp = buf +strlen (buf); + + tmp = *endp; + *endp ='\0' ; + +INIT_LIST_HEAD (&nidlist); +if (cfs_parse_nidlist (buf,strlen (buf), &nidlist) <=0 ) + rc =1 ; +cfs_free_nidlist (&nidlist); + + *endp = tmp; +if (rc) +return rc; +if (endh) + *endh = endp; +return 0 ; +} +/** Parse mount line options * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre * dev is passed as device=uml1:/lustre by mount.lustre
@@ -1006,20 +1104,18 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) clear++; }else if (strncmp (s1,"param=" ,6 ) ==0 ) {size_t length, params_length; -char *tail =strchr (s1 +6 ,',' ); +char *tail = s1; -if (!tail) { - length =strlen (s1); - }else { -lnet_nid_t nid; +if (lmd_find_delimiter (s1 +6 , &tail)) {char *param_str = tail +1 ;int supplementary =1 ; -while (!class_parse_nid_quiet (param_str, &nid, - ¶m_str)) { +while (!lmd_parse_nidlist (param_str, + ¶m_str)) supplementary =0 ; - } length = param_str - s1 - supplementary; + }else { + length =strlen (s1); } length -=6 ; params_length =strlen (lmd->lmd_params);
Signature · 1 line
1.8.3.1
PATCH 16/18 lustre: libcfs: restore original behavior in cfs_str2num_check
In reply to James SimmonsWhen cfs_str2num_check() moved from simple_strtoul to kstrtoul some of the functionality got lost. Restore handling hexidecimal number as well as '+' and '-'. Also handle any trailing spaces.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/32217
--- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +14 -3
@@ -214,8 +214,10 @@ char *cfs_firststr(char *str, size_t size) {bool all_numbers = true;char *endp, cache; +int len;int rc; + endp =strim (str);/** * kstrouint can only handle strings composed * of only numbers. We need to scan the string
@@ -228,16 +230,25 @@ char *cfs_firststr(char *str, size_t size)* After we are done the character at the * position we placed '\0' must be restored. */ -for (endp = str; endp < str + nob; endp++) { -if (!isdigit (*endp)) { + len =min ((int )strlen (endp), nob); +for (; endp < str + len; endp++) { +if (!isdigit (*endp) && *endp !='-' && + *endp !='+' ) { all_numbers = false;break ; } } + +/* Eat trailing space */ +if (!all_numbers &&isspace (*endp)) { + all_numbers = true; + endp--; + } + cache = *endp; *endp ='\0' ; - rc =kstrtouint (str,10 , num); + rc =kstrtouint (str,0 , num); *endp = cache;if (rc || !all_numbers)return 0 ;
Signature · 1 line
1.8.3.1
PATCH 16/18 lustre: libcfs: restore original behavior in cfs_str2num_check
Quoted 21 lines · James Simmons
When
cfs_str2num_check()moved fromsimple_strtoulto kstrtoul some of the functionality got lost. Restore handling hexidecimal number as well as '+' and '-'. Also handle any trailing spaces.Signed-off-by James Simmons <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/32217Reviewed-by John L. Hammond <[email protected]>Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Dmitry Eremin <[email protected]>Reviewed-by Oleg Drokin <[email protected]>Signed-off-by James Simmons <[email protected]>--- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)drivers/staging/lustre/lnet/libcfs/libcfs_string.c +0
-0
drivers/staging/lustre/lnet/libcfs/libcfs_string.c char *cfs_firststr(char *str, size_t size) · line 220
Quoted 7 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +2
-0@@ -214,8 +214,10 @@ char *cfs_firststr(char *str, size_t size) {bool all_numbers = true;char *endp, cache; +int len;int rc; + endp =strim (str);
This looks bad. The function now changes the string buffer, where it didn't before.
drivers/staging/lustre/lnet/libcfs/libcfs_string.c char *cfs_firststr(char *str, size_t size) · line 233
Quoted 10 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +1
-2/** * kstrouint can only handle strings composed * of only numbers. We need to scan the string @@ -228,16 +230,25 @@ char *cfs_firststr(char *str, size_t size)* After we are done the character at the * position we placed '\0' must be restored. */ -for (endp = str; endp < str + nob; endp++) { -if (!isdigit (*endp)) { + len =min ((int )strlen (endp), nob);
As endp might be different from 'str, 'nob' is not meaningful in the context of endp.
I'm guessing that mainline commit
Commit: c948390f10cc ("staging: lustre: llite: fix inconsistencies of root squash feature")
is related to this.
I cannot apply this patch as-is. It is broken. Possibly changing
endp = strim(str);
to
endp = str;
will fix it.
Thanks,
NeilBrown
Quoted 24 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +11
-1+for (; endp < str + len; endp++) { +if (!isdigit (*endp) && *endp !='-' && + *endp !='+' ) { all_numbers = false;break ; } } + +/* Eat trailing space */ +if (!all_numbers &&isspace (*endp)) { + all_numbers = true; + endp--; + } + cache = *endp; *endp ='\0' ; - rc =kstrtouint (str,10 , num); + rc =kstrtouint (str,0 , num); *endp = cache;if (rc || !all_numbers)return 0 ;Signature · 1 line
1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/26ac325d/attachment.sig>
PATCH 16/18 lustre: libcfs: restore original behavior in cfs_str2num_check
Quoted 30 lines · James Simmons
Quoted 28 lines
When
cfs_str2num_check()moved fromsimple_strtoulto kstrtoul some of the functionality got lost. Restore handling hexidecimal number as well as '+' and '-'. Also handle any trailing spaces.Signed-off-by James Simmons <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/32217Reviewed-by John L. Hammond <[email protected]>Reviewed-by Andreas Dilger <[email protected]>Reviewed-by Dmitry Eremin <[email protected]>Reviewed-by Oleg Drokin <[email protected]>Signed-off-by James Simmons <[email protected]>--- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)drivers/staging/lustre/lnet/libcfs/libcfs_string.c +1
-0@@ -214,8 +214,10 @@ char *cfs_firststr(char *str, size_t size) {bool all_numbers = true;char *endp, cache; +int len;int rc;
Quoted 4 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c char *cfs_firststr(char *str, size_t size) · line 220
Quoted 1 line
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +1
-0+ endp =strim (str);This looks bad. The function now changes the string buffer, where it didn't before.
So original this code uses simple_strtoul() which always parsed the string for numbers and succeded even if non digits existed in the string. In fact you could get pointer to the first non-digit. That was also used to trim the string. This behavior is very different from kstroul. I guess I will need to duplicate the string and free it at the end.
Quoted 5 lines
Quoted 5 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +0
-0/** * kstrouint can only handle strings composed * of only numbers. We need to scan the string @@ -228,16 +230,25 @@ char *cfs_firststr(char *str, size_t size)* After we are done the character at the
Quoted 8 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c char *cfs_firststr(char *str, size_t size) · line 233
Quoted 5 lines
drivers/staging/lustre/lnet/libcfs/libcfs_string.c +1
-2* position we placed '\0' must be restored. */ -for (endp = str; endp < str + nob; endp++) { -if (!isdigit (*endp)) { + len =min ((int )strlen (endp), nob);As endp might be different from 'str, 'nob' is not meaningful in the context of endp.
I believe nob is supposed to be the string length of "str" itself. We could error on the side caution and make that
len = min(strlen(endp), strlen(str));
Quoted 5 lines
I'm guessing that mainline commit
Commit:
c948390f10cc("staging: lustre: llite: fix inconsistencies of root squash feature")is related to this.
Actually it is commit ae0246da1603be7e7374621741515c2b6f2d6332 which ended up breaking my setup. I later debugged it and pushed the patch:
3ad6152d766039cb8ffd8633d971fb79402e5464
Later I pushed that patch to the OpenSFS branch and Hammond pointed out that some supported behaviors were lost. You can see this at:
https://review.whamcloud.com/#/c/32217/
Quoted 6 lines
I cannot apply this patch as-is. It is broken. Possibly changing
endp = strim(str);
to
endp = str;will fix it.
I do see that the trim thing was removed in the root squash handling. We might of returned a bug by mistake.
PATCH 17/18 lustre: ldlm: reduce mem footprint of ldlm_resource
In reply to James SimmonsFrom: Niu Yawei <[email protected]>
- Allocating lr_itree only for LDLM_EXTENT resource, reduced 120 bytes;
- Moving fields around to eliminate holes, eliminated 3 holes, reduced 4 bytes;
- Remove unused lr_contention_time, reduced 8 bytes;
Reduced 132 bytes in total.
WC-bug-id: https://jira.whamcloud.com/browse/LU-6775
Reviewed-on: http://review.whamcloud.com/15485
--- drivers/staging/lustre/lustre/include/lustre_dlm.h | 24 ++++++++-------- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 20 +++++++++++--- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 32 ++++++++++++++++------ 4 files changed, 54 insertions(+), 23 deletions(-)
drivers/staging/lustre/lustre/include/lustre_dlm.h +13 -11
@@ -819,6 +819,9 @@ struct ldlm_resource {*/ struct hlist_node lr_hash; +/** Reference count for this resource */ +atomic_t lr_refcount; +/** Spinlock to protect locks under this resource. */ spinlock_t lr_lock;
@@ -835,32 +838,31 @@ struct ldlm_resource {struct list_head lr_waiting;/** @} */ -/** Type of locks this resource can hold. Only one type per resource. */ -enum ldlm_type lr_type;/* LDLM_{PLAIN,EXTENT,FLOCK,IBITS} */ -/** Resource name */ struct ldlm_res_id lr_name; -/** Reference count for this resource */ -atomic_t lr_refcount;/** * Interval trees (only for extent locks) for all modes of this resource */ -struct ldlm_interval_tree lr_itree[LCK_MODE_NUM ]; +struct ldlm_interval_tree *lr_itree; + +/** Type of locks this resource can hold. Only one type per resource. */ +enum ldlm_type lr_type;/* LDLM_{PLAIN,EXTENT,FLOCK,IBITS} */ /** * Server-side-only lock value block elements. * To serialize lvbo_init. */ -struct mutex lr_lvb_mutex;int lr_lvb_len; +struct mutex lr_lvb_mutex; + +/** +* Associated inode, used only on client side. +*/ +struct inode *lr_lvb_inode; -/** When the resource was considered as contended. */ -unsigned long lr_contention_time;/** List of references to this resource. For debugging. */ struct lu_ref lr_reference; - -struct inode *lr_lvb_inode; };static inline bool ldlm_has_layout (struct ldlm_lock *lock)
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +1 -0
@@ -165,6 +165,7 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns,/* ldlm_lockd.c & ldlm_lock.c */ extern struct kmem_cache *ldlm_lock_slab; +extern struct kmem_cache *ldlm_interval_tree_slab;/* ldlm_extent.c */ void ldlm_extent_add_lock (struct ldlm_resource *res,struct ldlm_lock *lock);
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +16 -4
@@ -1129,15 +1129,26 @@ int ldlm_init(void)sizeof (struct ldlm_lock ),0 ,SLAB_HWCACHE_ALIGN | SLAB_TYPESAFE_BY_RCU, NULL); -if (!ldlm_lock_slab) { -kmem_cache_destroy (ldlm_resource_slab); -return -ENOMEM ; - } +if (!ldlm_lock_slab) + goto out_resource; + + ldlm_interval_tree_slab =kmem_cache_create ("interval_tree" , +sizeof (struct ldlm_interval_tree ) *LCK_MODE_NUM , +0 ,SLAB_HWCACHE_ALIGN , +NULL ); +if (!ldlm_interval_tree_slab) + goto out_lock;#if LUSTRE_TRACKS_LOCK_EXP_REFS class_export_dump_hook = ldlm_dump_export_locks;#endif return 0 ; + +out_lock: +kmem_cache_destroy (ldlm_lock_slab); +out_resource: +kmem_cache_destroy (ldlm_resource_slab); +return -ENOMEM ; }void ldlm_exit (void )
@@ -1151,4 +1162,5 @@ void ldlm_exit(void)*/ synchronize_rcu ();kmem_cache_destroy (ldlm_lock_slab); +kmem_cache_destroy (ldlm_interval_tree_slab); }
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +24 -8
@@ -44,6 +44,7 @@#include <linux/libcfs/libcfs_hash.h> struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab; +struct kmem_cache *ldlm_interval_tree_slab;int ldlm_srv_namespace_nr;int ldlm_cli_namespace_nr;
@@ -1001,10 +1002,9 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client) }/** Create and initialize new resource. */ -static struct ldlm_resource *ldlm_resource_new (void ) +static struct ldlm_resource *ldlm_resource_new (enum ldlm_type ldlm_type) {struct ldlm_resource *res; -int idx; res =kmem_cache_zalloc (ldlm_resource_slab,GFP_NOFS );if (!res)
@@ -1013,11 +1013,22 @@ static struct ldlm_resource *ldlm_resource_new(void)INIT_LIST_HEAD (&res->lr_granted);INIT_LIST_HEAD (&res->lr_waiting); -/* Initialize interval trees for each lock mode. */ -for (idx =0 ; idx <LCK_MODE_NUM ; idx++) { - res->lr_itree[idx].lit_size =0 ; - res->lr_itree[idx].lit_mode =1 << idx; - res->lr_itree[idx].lit_root =RB_ROOT_CACHED ; +if (ldlm_type ==LDLM_EXTENT ) { +int idx; + + res->lr_itree =kmem_cache_zalloc (ldlm_interval_tree_slab, +GFP_NOFS ); +if (!res->lr_itree) { +kmem_cache_free (ldlm_resource_slab, res); +return NULL ; + } + +/* Initialize interval trees for each lock mode. */ +for (idx =0 ; idx <LCK_MODE_NUM ; idx++) { + res->lr_itree[idx].lit_size =0 ; + res->lr_itree[idx].lit_mode =1 << idx; + res->lr_itree[idx].lit_root =RB_ROOT_CACHED ; + } }atomic_set (&res->lr_refcount,1 );
@@ -1070,7 +1081,7 @@ struct ldlm_resource *LASSERTF (type >=LDLM_MIN_TYPE && type <LDLM_MAX_TYPE ,"type: %d\n" , type); - res =ldlm_resource_new (); + res =ldlm_resource_new (type);if (!res)return ERR_PTR (-ENOMEM );
@@ -1089,6 +1100,9 @@ struct ldlm_resource *lu_ref_fini (&res->lr_reference);/* We have taken lr_lvb_mutex. Drop it. */ mutex_unlock (&res->lr_lvb_mutex); +if (res->lr_itree) +kmem_cache_free (ldlm_interval_tree_slab, + res->lr_itree);kmem_cache_free (ldlm_resource_slab, res); lvbo_init: res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
@@ -1167,6 +1181,8 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, ns->ns_lvbo->lvbo_free (res);if (cfs_hash_bd_count_get (bd) ==0 )ldlm_namespace_put (ns); +if (res->lr_itree) +kmem_cache_free (ldlm_interval_tree_slab, res->lr_itree);kmem_cache_free (ldlm_resource_slab, res); }
Signature · 1 line
1.8.3.1
PATCH 18/18 lustre: update version to 2.8.99
In reply to James SimmonsWith the missing patches from the lustre 2.9 release merged upstream its time to update the upstream client's version.
--- drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h +2 -2
@@ -2,10 +2,10 @@#define _LUSTRE_VER_H_#define LUSTRE_MAJOR 2 -#define LUSTRE_MINOR 6 +#define LUSTRE_MINOR 8#define LUSTRE_PATCH 99#define LUSTRE_FIX 0 -#define LUSTRE_VERSION_STRING "2.6.99" +#define LUSTRE_VERSION_STRING "2.8.99"#define OBD_OCD_VERSION (major, minor, patch, fix) \ (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))
Signature · 1 line
1.8.3.1
PATCH 18/18 lustre: update version to 2.8.99
James, thanks for pushing up these patches.
Why not use 2.9.0? Are there still patches missing, or do you want this version to distinguish it from the actual 2.9.0 release?
Cheers, Andreas
Quoted 30 lines · James Simmons
With the missing patches from the lustre 2.9 release merged upstream its time to update the upstream client's version.
Signed-off-by James Simmons <[email protected]>---
drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h +2
-2@@ -2,10 +2,10 @@#define _LUSTRE_VER_H_#define LUSTRE_MAJOR 2 -#define LUSTRE_MINOR 6 +#define LUSTRE_MINOR 8#define LUSTRE_PATCH 99#define LUSTRE_FIX 0 -#define LUSTRE_VERSION_STRING "2.6.99" +#define LUSTRE_VERSION_STRING "2.8.99"#define OBD_OCD_VERSION (major, minor, patch, fix) \ (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))Signature · 1 line
1.8.3.1
PATCH 18/18 lustre: update version to 2.8.99
Quoted 5 lines
James, thanks for pushing up these patches.
Why not use 2.9.0? Are there still patches missing, or do you want this version to distinguish it from the actual 2.9.0 release?
Oleg asked that I use a version number never used by an offical release. Should we can that policy? Anyways their might be stuff missing still. Once we reach the 2.10 LTS release we can do a scan of the code to see if this is the case.
Quoted 33 lines
Cheers, Andreas
Quoted 30 lines · James Simmons
With the missing patches from the lustre 2.9 release merged upstream its time to update the upstream client's version.
Signed-off-by James Simmons <[email protected]>---
drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/lustre/include/uapi/linux/lustre/lustre_ver.h +2
-2@@ -2,10 +2,10 @@#define _LUSTRE_VER_H_#define LUSTRE_MAJOR 2 -#define LUSTRE_MINOR 6 +#define LUSTRE_MINOR 8#define LUSTRE_PATCH 99#define LUSTRE_FIX 0 -#define LUSTRE_VERSION_STRING "2.6.99" +#define LUSTRE_VERSION_STRING "2.8.99"#define OBD_OCD_VERSION (major, minor, patch, fix) \ (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))Signature · 1 line
1.8.3.1
cover lustre: missing updates from lustre 2.9
In reply to James SimmonsQuoted 12 lines · James Simmons
This patch set fills in the known missing pieces from the Lustre 2.9 release. With these patches this brings us to the pre-2.10 development cycle. The grant allocation fixes were missing as well as security hole closes. The rest are small changes in addition to support for filesets and ladvise feature.
Alexander Boyko (1):
lustre: obd: add callback forllog_cat_process_or_forkBobi Jam (1):
lustre: osc:max_pages_per_rpcshould be chunk size aligned
Quoted 8 lines
Fan Yong (1):
lustre: ptlrpc: properly set "rq_xid" for 4MB IOHenri Doreau (1):
lustre: llite: restorefd_ochwhen putting leaseJames Simmons (2):
lustre: libcfs: restore original behavior incfs_str2num_check
Apart from this patch which I couldn't bring myself to apply, I've applied all these patches - making changes to only one as mentioned below.
I'll probably add some cleanups later as separately described.
Quoted 11 lines
lustre: update version to 2.8.99
Jian Yu (1):
lustre: mount: fixlmd_parse()to handle new delimitersJinshan Xiong (1):
lustre: llite: fast read implementationJohann Lombardi (1):
lustre: grant: add support forOBD_CONNECT_GRANT_PARAM
Quoted 7 lines
John L. Hammond (3):
lustre: obd: renamemd_getstatus()tomd_get_root()
lustre: obd: reserve connection flagOBD_CONNECT2_FILE_SECCTX
lustre: security: send file security context for createsLai Siyao (1):
lustre: fileset: add fileset mount support
When I removed the union name as promised, this went from
14 files changed, 135 insertions(+), 43 deletions(-) to 14 files changed, 120 insertions(+), 28 deletions(-)
Not an enormous change, but worthwhile I think.
Thanks
NeilBrown
Quoted 57 lines
Li Xi (3):
lustre: ladvise: Add feature of giving file access advices
lustre: ladvise: Add willread advice support for ladvise
lustre: ladvise: Add dontneed advice support for ladviseNiu Yawei (1):
lustre: ldlm: reduce mem footprint ofldlm_resourcePatrick Farrell (1):
lustre: llite: ladvise protocol changes.../lustre/include/uapi/linux/lustre/lustre_idl.h | 52 ++- .../lustre/include/uapi/linux/lustre/lustre_user.h | 51 +++ .../lustre/include/uapi/linux/lustre/lustre_ver.h | 4 +- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 17 +- drivers/staging/lustre/lustre/include/cl_object.h | 13 + .../staging/lustre/lustre/include/lustre_disk.h | 2 + drivers/staging/lustre/lustre/include/lustre_dlm.h | 24 +- .../staging/lustre/lustre/include/lustre_import.h | 1 + .../lustre/lustre/include/lustre_req_layout.h | 10 +- .../staging/lustre/lustre/include/lustre_swab.h | 2 + drivers/staging/lustre/lustre/include/obd.h | 17 +- drivers/staging/lustre/lustre/include/obd_class.h | 16 +- .../staging/lustre/lustre/include/obd_support.h | 5 +- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 20 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 32 +- drivers/staging/lustre/lustre/llite/dir.c | 54 +++- drivers/staging/lustre/lustre/llite/file.c | 360 ++++++++++++++++++--- .../staging/lustre/lustre/llite/llite_internal.h | 34 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 37 ++- drivers/staging/lustre/lustre/llite/llite_mmap.c | 34 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 38 +++ drivers/staging/lustre/lustre/llite/namei.c | 40 ++- drivers/staging/lustre/lustre/llite/rw.c | 68 +++- drivers/staging/lustre/lustre/llite/vvp_internal.h | 1 + drivers/staging/lustre/lustre/llite/vvp_io.c | 3 + .../staging/lustre/lustre/llite/xattr_security.c | 38 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 34 +- drivers/staging/lustre/lustre/lov/lov_io.c | 28 ++ drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 + drivers/staging/lustre/lustre/mdc/mdc_lib.c | 32 ++ drivers/staging/lustre/lustre/mdc/mdc_locks.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_reint.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_request.c | 50 ++- drivers/staging/lustre/lustre/obdclass/cl_io.c | 2 + drivers/staging/lustre/lustre/obdclass/llog_cat.c | 16 +- .../lustre/lustre/obdclass/lprocfs_status.c | 72 ++++- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 135 +++++++- drivers/staging/lustre/lustre/osc/lproc_osc.c | 18 ++ drivers/staging/lustre/lustre/osc/osc_cache.c | 95 ++++-- .../staging/lustre/lustre/osc/osc_cl_internal.h | 1 + drivers/staging/lustre/lustre/osc/osc_dev.c | 1 + drivers/staging/lustre/lustre/osc/osc_internal.h | 4 + drivers/staging/lustre/lustre/osc/osc_io.c | 79 +++++
Quoted 11 lines
drivers/staging/lustre/lustre/osc/osc_request.c | 184 +++++++++-- drivers/staging/lustre/lustre/ptlrpc/client.c | 9 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 10 + drivers/staging/lustre/lustre/ptlrpc/layout.c | 66 +++- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 3 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 27 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 122 +++++-- 52 files changed, 1722 insertions(+), 259 deletions(-)Signature · 1 line
1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180703/51b3eeb3/attachment.sig>