LLAPI\_LAYOUT\_OST\_INDEX\_GET(3) Lustre Library Functions LLAPI\_LAYOUT\_OST\_INDEX\_GET(3)

# [NAME](#NAME)

llapi\_layout\_ost\_index\_get, llapi\_layout\_ost\_index\_set - get or set the OST index of a stripe of a Lustre file

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
```

```
int llapi_layout_ost_index_get(const struct llapi_layout *layout,
                               int stripe_number, uint64_t *ost_index);
```

```
int llapi_layout_ost_index_set(struct llapi_layout *layout,
                               int stripe_number, uint64_t ost_index);
```

# [DESCRIPTION](#DESCRIPTION)

**llapi\_layout\_ost\_index\_get()** stores into *ost\_index* the index number of the Lustre OST associated with *stripe\_number* in *layout*.

**llapi\_layout\_ost\_index\_set()** sets the OST index of *stripe\_number* in *layout* to *ost\_index*. This allows an application to control which OSTs will be used to allocate storage for a file. Setting the starting OST index for a file (*stripe\_number*=0) is supported with all versions of Lustre, and other stripes in the file will be assigned sequentially by the filesystem. Setting the OST indices other than stripe 0 is only supported with Lustre 2.7 and later, and will return an error at file creation time for 2.6 and earlier.

It is an error to call **llapi\_layout\_ost\_index\_get()** with a *layout* that was not initialized with one of **llapi\_layout\_get\_by\_fd()**, **llapi\_layout\_get\_by\_fid()**, or **llapi\_layout\_get\_by\_path()**.

An *ost\_index* value of **LLAPI\_LAYOUT\_DEFAULT** is only valid for *stripe\_number*=0 and means that an OST index will be automatically assigned by the filesystem and will reset previously-set *stripe\_number* assignments.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_layout\_ost\_index\_get()** and **llapi\_layout\_ost\_index\_set()** return 0 on success, or -1 if an error occurred (in which case, errno is set appropriately).

# [ERRORS](#ERRORS)

[**EINVAL**](#EINVAL)

An invalid argument was specified.

[**EOPNOTSUPP**](#EOPNOTSUPP)

Attempted to set index of a stripe other than stripe 0.

# [AVAILABILITY](#AVAILABILITY)

**llapi\_layout\_ost\_index\_get()** and **llapi\_layout\_ost\_index\_set()** are part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.7.0

# [SEE ALSO](#SEE_ALSO)

[**llapi\_layout\_alloc**(3)](/man/enterprise-packages/lustre/llapi_layout_alloc.3), [**llapi\_layout\_file\_open**(3)](/man/enterprise-packages/lustre/llapi_layout_file_open.3), [**llapi\_layout**(7)](/man/enterprise-packages/lustre/llapi_layout.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2024-08-27 Lustre User API

---

Document: llapi_layout_ost_index_set(3) from lustre 2.17.59-r2 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
